Orthogonal projection and least squares

The closest point of a subspace to a vector is its orthogonal projection, which is why the least squares solution of Ax equal to b solves the normal equations.

From Linear algebra, with proofs.