The projection should be the point in \(\spn{\yy}\) that is as close as possible to \(\xx\text{.}\) Therefore we need to minimize \(\norm{\xx-\alpha\yy}\) over \(\alpha\text{,}\) which is equivalent to minimizing \(\dotprod{\xx-\alpha\yy,\xx-\alpha\yy}\text{.}\) If we expand this inner product, we get
\begin{equation*}
\dotprod{\xx-\alpha\yy,\xx-\alpha\yy} = \norm{\xx}^2 - 2\alpha\dotprod{\xx,\yy} + \alpha^2\norm{\yy}^2\text{.}
\end{equation*}
This expression is quadratic in \(\alpha\) and can be simplified by completing the square in \(\alpha\text{:}\)
\begin{align*}
\norm{\xx}^2 - 2\alpha\dotprod{\xx,\yy} + \alpha^2\norm{\yy}^2 & = \norm{\yy}^2\left(\alpha^2 - \frac{2\alpha}{\norm{\yy}^2}\dotprod{\xx,\yy}\right) + \norm{\xx}^2 \\
& = \norm{\yy}^2\left(\alpha - \frac{\dotprod{\xx,\yy}}{\norm{\yy}^2}\right)^2 - \frac{\dotprod{\xx,\yy}^2}{\norm{\yy}^2} + \norm{\xx}^2
\end{align*}
Therefore the value of \(\alpha\) that makes this quantity as small as possible must be \(\alpha = \frac{\dotprod{\xx,\yy}}{\norm{\yy}^2}\text{,}\) which means that
\begin{equation*}
\proj{\yy}{\xx} = \alpha\yy = \frac{\dotprod{\xx,\yy}}{\dotprod{\yy,\yy}}\yy\text{.}
\end{equation*}