Statistical Mechanics of Generalization in Kernel Regression and Wide Neural Networks