I'm currently learning about matrices and was asked to show that this formula works for powers of $M$. $$M^n = nM-(n-1)I$$ Where $M$ is the matrix (show below), $n$ is the exponent an $I$ is the identity matrix.
$$ M = \begin{bmatrix} 3 & -1\\ 4 & -1 \end{bmatrix} $$
I then tried this on other matrices such as $$ M = \begin{bmatrix} 1 & 2 & 3 \\ 4 & 5 & 6 \\ 7 & 8 & 9 \\ \end{bmatrix} $$
However I found that the formula did not work. Why is it so and under what constraints will this formula work?