Fitting is easy; trusting is not
Stochastic and adaptive optimizers explained how to approach a training minimum. Least squares showed why that minimum can still be unstable. Nearly duplicate features allow large cancelling weights, and a flexible model can fit sampling noise. Regularization changes the objective itself.
We use the unaveraged squared error . Features are centred and scaled using training data; the target is centred. The intercept is restored afterward and is not penalized. The numerical value of a penalty parameter depends on this normalization.
A weight changes when its feature's units change. Penalizing weights without controlling units therefore changes the model's preference. Fit the scaler inside each training fold, then apply that fitted transform to the validation fold. A penalty can reduce variance at the cost of bias; it does not guarantee lower prediction error for every dataset.