DEFINITION :The vectors $q_1, ... , q_n$ are orthonormal if
$$ q_i^Tq_j=\begin{cases}0\quad when\ \,i\neq j\\ 1 \quad when \ \,i=j\end{cases} $$
A matrix with orthonormal columns is assigned the special letter $Q$.
The matrix $Q$ is easy to work with because $Q^T Q =$ I. This repeats in matrix language that the columns $q_1 , ... , q_n$ are orthonormal.
$Q$ is not required to be square.
When $Q$ is square, $Q^T Q = I$ means that $Q^T= Q^{-1}$.In this case we call $Q$ an orthogonal matrix
$(Qx)^T(Qx)=x^TQ^TQx=x^TIx=x^Tx$
The least squares solution of $Qx = b$ is $x = Q^T b$. The projection matrix is $QQ^T$ .
Gram-Schmidt : Subtract from every new vector its projections in the directions already set
Begin by choosing $A = a$. This first direction is accepted as it comes. The next direction $B$ must be perpendicular to $A$. Start with $b$ and subtract its projection along $A.$ This leaves the perpendicular part, which is the orthogonal vector B:
$$ First\ Gram{-}Schmidt\ step\qquad B=b-\frac{A^Tb}{A^TA}A $$
That time,$A$ and $B$ are orthogonal (Veify:$A^TB=A^Tb-A^Tb=0$)
The third direction starts with $c$. This is not a combination of $A$ and $B$ (because $c$ is not a combination of $a$ and $b$). But most likely $c$ is not perpendicular to $A$ and $B$. So subtract off its components in those two directions to get a perpendicular direction $C$:
$$ Next\ Grcam{-}Schmidt\ step\qquad C=c-\frac{A^Tc}{A^TA}A-\frac{B^Tc}{B^TB}B $$