Let's show that the matrix element $m_{i,j}=0$ for $i\neq j$:
make the following new basis
$u_a=v_a$ except $a=i$ where $u_i=v_i+v_j$
which corresponds to the matrix $A$ being almost identity except the off-diagonal element $A_{ij}=1$
After that we have $A^{-1}MA=M$ which implies that $m_{i,j}=0$ and also $m_{ii}=m_{jj}$
Repeating the same procedure for different $i\neq j$ we conclude that all off-diagonal elements are zero and the diagonal elements are all equal.
To exemplify the method take $4\times 4$ matrix M:
$$
M=\left(
\begin{array}{cccc}
m_{1,1} & m_{1,2} & m_{1,3} & m_{1,4} \\
m_{2,1} & m_{2,2} & m_{2,3} & m_{2,4} \\
m_{3,1} & m_{3,2} & m_{3,3} & m_{3,4} \\
m_{4,1} & m_{4,2} & m_{4,3} & m_{4,4} \\
\end{array}
\right)
$$
and $i=1$ $j=2$ to get for $A^{-1}.M.A-M$:
$$
\left(
\begin{array}{cccc}
-m_{2,1} & m_{1,1}-m_{2,1}-m_{2,2} & -m_{2,3} & -m_{2,4} \\
0 & m_{2,1} & 0 & 0 \\
0 & m_{3,1} & 0 & 0 \\
0 & m_{4,1} & 0 & 0 \\
\end{array}
\right)
$$
which implies that $m_{2,1}=0$ and $m_{1,1}=m_{2,2}$