Denote by $p(x)$ the characteristic polynomial of $M\in C^{n\times n}$. If $f(x)$ is a polynomial different from the zero polynomial such that $f(M)=0$ then $p(x)\mid f^n(x)$.
Proof:
${\rm deg} \ p(x)=n$ and ${\rm deg} \ f^n(x)\geq n$.
Note that ${\rm deg}\ f(x)\geq 1$, because if it was order $0$,
then $f(x)$ would be a constant and hence $f(M)\neq 0$,
and $f(x)\neq 0$, as given.
Hence ${\rm deg}\ f^n(x)\geq {\rm deg}\ p(x)$, and accordingly $f^n(x)$ can be divided by $p(x)$ using the division theorem:
$$f^n(x)=q(x)p(x)+r(x)$$
Let $m(x)$ be the minimal polynomial of $M$. Then $m(x)\mid p(x)$, or
$$p(x)=q_1(x)m(x)$$.
Therefore
$$f^n(x)=q(x)q_1(x)m(x)+r(x)$$
Say that $r(x)\neq 0$, i.e. say that $r(x)$ is not the zero polynomial.
Then we obtain that $m(x)\nmid f^n(x)$. This is a contradiction because any polynomial annihilated by $M$ is divided by the minimal polynomial.
Hence $r(x)=0$, $\therefore$
$$f^n(x)=q(x)p(x)$$
Hence $p(x)\mid f^n(x)$.