Least squares chooses the line that minimizes total squared vertical error.
For fixed x=0,1,2, setting both partial derivatives of the error to zero gives residual sum zero and x-weighted residual sum zero. Solving yields m=(y₂−y₀)/2 and c=mean(y)−m. The distinct x-values make the two-column design matrix full rank and the optimum unique.
This fit minimizes vertical distances, not perpendicular distances.