Is $A^{q+2}=A^2$ in $M_2(\mathbb{Z}/p\mathbb{Z})$?

I'm wondering, why is it that for $q=(p^2-1)(p^2-p)$, that $A^{q+2}=A^2$ for any $A\in M_2(\mathbb{Z}/p\mathbb{Z})$?

It's not hard to see that $GL_2(\mathbb{Z}/p\mathbb{Z})$ has order $(p^2-1)(p^2-p)$, and so $A^q=1$ if $A\in GL_2(\mathbb{Z}/p\mathbb{Z})$, and so the equation holds in that case. But if $A$ is not invertible, why does the equality still hold?

-

If $A$ is not invertible, then its characteristic polynomial is either $x^2$ or $x(x-a)$ for some $a\in\mathbb{Z}/p\mathbb{Z}$. In the former case, by the Cayley-Hamilton Theorem we have $A^2 = 0$, hence $A^{q+2}=A^2$. In the latter case, the matrix is similar to a diagonal matrix, with $0$ in one diagonal and $a$ in the other. So, up to conjugation, we have $$A^{q+2}=\left(\begin{array}{cc} 0 & 0\\ 0 & a\end{array}\right)^{q+2} = \left(\begin{array}{cc} 0 & 0\\ 0 & a^{q+2} \end{array}\right).$$ But $a^{p} = a$. Since $q = p^4 -p^3-p^2 + p$, we have $$a^{q} = \frac{a^{p^4}a^p}{a^{p^3}a^{p^2}} = 1$$ so $a^{q+2} = a^2$, hence $A^{q+2}=A^2$.
Thanks! (By the way, is the exponent supposed to be $q+2$ in the first displayed set of equalities?) –  Tiffany Hwang Jun 16 '12 at 6:26