We can deduce geometrically that
$$
\begin{pmatrix}
\boldsymbol e_r\\
\boldsymbol e_\theta\\
\boldsymbol e_\phi
\end{pmatrix}
=
\begin{pmatrix}
\sin\theta\cos\phi & \sin\theta\sin\phi & \cos\theta\\
\cos\theta\cos\phi & \cos\theta\sin\phi & -\sin\theta\\
-\sin\phi & \cos\phi & 0
\end{pmatrix}
\begin{pmatrix}
\boldsymbol i\\
\boldsymbol j\\
\boldsymbol k
\end{pmatrix}
$$
Furthermore, we know that the vector is invariant under change of coordinates and therefore the cartesian and spherical vectors are equal:
$$\begin{aligned}
\boldsymbol{A_x}&=(A_x, A_y, A_z)
\begin{pmatrix}
\boldsymbol i\\
\boldsymbol j\\
\boldsymbol k
\end{pmatrix}\\
&=
(A_x, A_y, A_z)
\begin{pmatrix}
\sin\theta\cos\phi & \sin\theta\sin\phi & \cos\theta\\
\cos\theta\cos\phi & \cos\theta\sin\phi & -\sin\theta\\
-\sin\phi & \cos\phi & 0
\end{pmatrix}^{-1}
\begin{pmatrix}
\sin\theta\cos\phi & \sin\theta\sin\phi & \cos\theta\\
\cos\theta\cos\phi & \cos\theta\sin\phi & -\sin\theta\\
-\sin\phi & \cos\phi & 0
\end{pmatrix}
\begin{pmatrix}
\boldsymbol i\\
\boldsymbol j\\
\boldsymbol k
\end{pmatrix}\\
&=
(A_r, A_\theta, A_\phi)
\begin{pmatrix}
\boldsymbol e_r\\
\boldsymbol e_\theta\\
\boldsymbol e_\phi
\end{pmatrix}=\boldsymbol{A_r}
\end{aligned}$$
Since the spherical coordinates are orthonormal this means the change of basis matrix satisfies $\mathbf R\,\mathbf R^\top=1\!\!1$, namely, $\mathbf R^\top=\mathbf R^{-1}$.
Thence,
$$
\begin{aligned}
\begin{pmatrix}
A_r\\
A_\theta\\
A_\phi
\end{pmatrix}
&=\left((A_x, A_y, A_z)
\begin{pmatrix}
\sin\theta\cos\phi & \sin\theta\sin\phi & \cos\theta\\
\cos\theta\cos\phi & \cos\theta\sin\phi & -\sin\theta\\
-\sin\phi & \cos\phi & 0
\end{pmatrix}^{-1}\right)^\top\\
&=\left((A_x, A_y, A_z)
\begin{pmatrix}
\sin\theta\cos\phi & \sin\theta\sin\phi & \cos\theta\\
\cos\theta\cos\phi & \cos\theta\sin\phi & -\sin\theta\\
-\sin\phi & \cos\phi & 0
\end{pmatrix}^{\top}\right)^\top\\
&=
\begin{pmatrix}
\sin\theta\cos\phi & \sin\theta\sin\phi & \cos\theta\\
\cos\theta\cos\phi & \cos\theta\sin\phi & -\sin\theta\\
-\sin\phi & \cos\phi & 0
\end{pmatrix}
\begin{pmatrix}
A_x\\
A_y\\
A_z
\end{pmatrix}
\end{aligned}
$$
which is what your teacher gave you.
Now let's subtitute $A_x=r\sin\theta\cos\phi$, $A_y=r\sin\theta\sin\phi$ and $A_z=r\cos\theta$ and multiply. This means
$$
\begin{aligned}
&\begin{aligned}
\color{blue}{A_r}&=A_x\sin\theta\cos\phi+A_y\sin\theta\sin\phi+A_z\cos\theta\\
&=r\sin^2\theta\cos^2\phi+r\sin^2\theta\sin^2\phi+r\cos^2\theta\\
&=r\sin^2\theta+rcos^2\theta\color{blue}{=r}
\end{aligned}\\
\\
&\begin{aligned}
\color{green}{A_\theta}&=A_x\cos\theta\cos\phi+A_y\cos\theta\sin\phi-A_z\sin\theta\\
&=r\sin\theta\cos\theta\cos^2\phi+r\sin\theta\cos\theta\sin^2\phi-r\sin\theta\cos\theta\\
&\hspace{0.1cm} \color{green}{=0}
\end{aligned}\\
\\
&\begin{aligned}
\color{red}{A_\phi}&=-A_x\sin\phi+A_y\cos\phi\\
&=-r\sin\theta\cos\phi\sin\phi+r\sin\theta\sin\phi\cos\phi\\
&\hspace{0.1cm} \color{red}{=0}
\end{aligned}
\end{aligned}
$$
This is why when you inputted the point $\mathsf P(2,2,2\sqrt 2)$ you got $(||\mathsf P(2,2,2\sqrt 2)||,0,0)=(4,0,0)$. In fact, any position vector/point can be described by $r\,\boldsymbol e_r(\theta,\phi)$.