Example 14 (2004 Silk Road Mathematical Competition) Find all prime numbers $p$ such that there exist integers $m, n$ satisfying $p=m^{2}+n^{2}$, and $p \mid\left(m^{3}+n^{3}-4\right)$.
When $|m|, |n| \leqslant 3$, the primes $2=1^{2}+1^{2}, 5=1^{2}+2^{2}, 13=(-3)^{2}+(-2)^{2}$ satisfy the condition.
Below, we prove that only these primes satisfy the condition.
From $p=m^{2}+n^{2}$, we get $m n=\frac{(m+n)^{2}-p}{2}$, thus, we have
$$
\begin{aligned}
m^{3}+n^{3}-4 & =(m+n)^{3}-3(m+n) m n-4 \\
& =\frac{-(m+n)^{3}+3 p(m+n)-8}{2} .
\end{aligned}
$$

Given $p \mid\left(m^{3}+n^{3}-4\right)$, it follows that $p \mid\left[(m+n)^{3}+8\right]$.
Thus, either $p \mid(m+n+2)$; or $\left.p \mid[m+n)^{2}-2(m+n)+4\right]$, which, when $p>2$, is equivalent to $p \mid(m n-m-n+2)$.
(1) $p \mid(m+n+2)$.
Note that $m^{2}+n^{2} \leqslant|m+n+2|$.
Xue
Lin
Yuan
Ke
Shu
Xue
Zhong
De
Shu
Lun
Wen
Ti
When $m^{2}+n^{2} \leqslant m+n+2$, we have
$(2 m-1)^{2}+(2 n-1)^{2} \leqslant 10$, which gives $-1 \leqslant m, n \leqslant 2$;
When $m^{2}+n^{2} \leqslant-(m+n+2)$, we have
$(2 m+1)^{2}+(2 n+1)^{2} \leqslant-6$, which has no solution.
(2) $p \mid(m n-m-n+2)$.

Note that $m^{2}+n^{2} \leqslant|m n-m-n+2|$.
When $m^{2}+n^{2} \leqslant m n-m-n+2$, we have
$(2 m-n+1)^{2}+3(n+1)^{2} \leqslant 12$, which gives $-3 \leqslant m, n \leqslant 1$;
When $m^{2}+n^{2} \leqslant-(m n-m-n+2)$, we have
$(2 m+n-1)^{2}+3\left(n-\frac{1}{3}\right)^{2} \leqslant-\frac{20}{3}$, which has no solution.