Otherwise, $p\mid M$. Then the assertion $M\equiv a^{p-1}M\pmod p$ would be true for any $a$. And if this assertion is always true, you can't deduce that $a^{p-1}\equiv1\pmod p$ happens sometimes.
0
Bumbble Comm
On
Otherwise, $p \mid M$, so cancellation of $M \equiv 0 \pmod 0$ on both sides is not legitimate under $\pmod p$. In fact, you have
$$M - a^{p-1}M = M (1 - a^{p-1}),$$
which is divisible by $p$ for whatever $a$, so you can't conclude anything about $a^{p-1} \pmod p$.
Otherwise, $p\mid M$. Then the assertion $M\equiv a^{p-1}M\pmod p$ would be true for any $a$. And if this assertion is always true, you can't deduce that $a^{p-1}\equiv1\pmod p$ happens sometimes.