[guided]Assume that $|Az|=|z|$ for every vector $z\in\mathbb{R}^n$. We want to prove a stronger-looking statement: $A$ preserves not only lengths, but also angles, equivalently inner products. The tool that converts norm information into inner product information over $\mathbb{R}$ is the elementary expansion of $|x+y|^2$ and $|x-y|^2$.
First, squaring the hypothesis is valid because both sides are non-negative real numbers. Thus, for every $z\in\mathbb{R}^n$,
\begin{align*}
|Az|^2=|z|^2.
\end{align*}
Let $x,y\in\mathbb{R}^n$. The real polarization identity comes from expanding the two squared norms using bilinearity and symmetry of the Euclidean inner product:
\begin{align*}
|x+y|^2=\langle x+y,x+y\rangle=|x|^2+2\langle x,y\rangle+|y|^2.
\end{align*}
Similarly,
\begin{align*}
|x-y|^2=\langle x-y,x-y\rangle=|x|^2-2\langle x,y\rangle+|y|^2.
\end{align*}
Subtracting the second identity from the first gives
\begin{align*}
|x+y|^2-|x-y|^2=4\langle x,y\rangle.
\end{align*}
Now apply the same identity to the vectors $Ax$ and $Ay$. Since $A$ is a matrix, the map $z\mapsto Az$ is linear, so $Ax+Ay=A(x+y)$ and $Ax-Ay=A(x-y)$. Hence
\begin{align*}
4\langle Ax,Ay\rangle=|Ax+Ay|^2-|Ax-Ay|^2.
\end{align*}
Using linearity of $A$, this becomes
\begin{align*}
4\langle Ax,Ay\rangle=|A(x+y)|^2-|A(x-y)|^2.
\end{align*}
The hypothesis applies to every vector of $\mathbb{R}^n$, in particular to $x+y$ and $x-y$. Therefore
\begin{align*}
|A(x+y)|^2=|x+y|^2.
\end{align*}
Also,
\begin{align*}
|A(x-y)|^2=|x-y|^2.
\end{align*}
Substituting these two equalities gives
\begin{align*}
4\langle Ax,Ay\rangle=|x+y|^2-|x-y|^2.
\end{align*}
By the polarization identity already verified,
\begin{align*}
|x+y|^2-|x-y|^2=4\langle x,y\rangle.
\end{align*}
Thus
\begin{align*}
4\langle Ax,Ay\rangle=4\langle x,y\rangle.
\end{align*}
Dividing by $4$ gives
\begin{align*}
\langle Ax,Ay\rangle=\langle x,y\rangle.
\end{align*}
Because $x$ and $y$ were arbitrary vectors in $\mathbb{R}^n$, the matrix $A$ preserves the Euclidean inner product on all pairs of vectors.[/guided]