Example 4 Find all prime numbers $p$ such that there are exactly $p$ integer pairs $(x, y)$ satisfying $0 \leqslant x, y \leqslant p$ and $y^{2} \equiv x^{3}-x(\bmod p)$.
Prove that for $f(x)=x^{3}-x$, $f(x)$ is an odd function. When $p=2$, $y^{2} \equiv f(x)(\bmod p)$ has exactly two solutions $(0,0),(1,0)$.
When $p \equiv 3(\bmod 4)$, since
$\left(\frac{-a}{p}\right)=\left(\frac{-1}{p}\right) \cdot\left(\frac{a}{p}\right)=-\left(\frac{a}{p}\right)$ (using property (iV)),
thus, $y^{2} \equiv f(x)$ and $y^{2} \equiv -f(x) \equiv f(-x)$ have one with a solution and one without a solution.
Assume that among $x=2,3, \cdots, \frac{p-1}{2}$, $y^{2} \equiv f(x)(\bmod p)$ has $k$ solutions, then among $x=\frac{p+1}{2}, \frac{p+3}{2}, \cdots, p-2$, $y^{2} \equiv f(x)(\bmod p)$ has $\frac{p-3}{2}-k$ solutions.
Therefore, among $x=2,3, \cdots, p-2$, $y^{2} \equiv f(x)(\bmod p)$ has $\left(\frac{p-3}{2}-k\right)+k$ solutions.
For each $x=2,3, \cdots, p-2$, since $y^{2} \equiv d(\bmod p)$ must have two solutions, hence for $x=2,3, \cdots, p-2$, $y^{2} \equiv d(\bmod p)$ has $2 \times \frac{p-3}{2}=p-3$ integer pairs $(x, y)$ satisfying the condition.
When $x=0,1, p-1$, $y^{2} \equiv f(x) \equiv 0(\bmod p)$ each has only one integer pair satisfying the condition.
Therefore, when $p \equiv 3(\bmod 4)$, the congruence equation has $p$ solutions.
When $p \equiv 1(\bmod 4)$,
since $\left(\frac{-a}{p}\right)=\left(\frac{-1}{p}\right) \cdot\left(\frac{a}{p}\right)=\left(\frac{a}{p}\right)$, thus
$y^{2} \equiv f(x)$ and $y^{2} \equiv f(-x)$ either both have two solutions or both have no solutions.
Assume that among $x=2,3, \cdots, \frac{p-1}{2}$, $y^{2} \equiv f(x)(\bmod p)$ has $k$ solutions, then among $x=\frac{p+1}{2}, \frac{p+3}{2}, \cdots, p-2$, $y^{2} \equiv f(x)$ has $k$ solutions.
Similarly to the case of $p \equiv 3(\bmod 4)$, we know that among $x=2,3, \cdots, p-2$, $y^{2} \equiv f(x)(\bmod p)$ has $2 \times(k+k)$ pairs $(x, y)$ satisfying the condition.
When $x=0,1, p-1$, $y^{2} \equiv f(x) \equiv 0(\bmod p)$ each has one pair $(x, y)$ satisfying the requirement.
Therefore, there are $4 k+3$ solutions in total, and since $p \equiv 1(\bmod 4)$,
thus $p \equiv 1(\bmod 4)$ must not satisfy the condition.
In summary, $p=2$ or $p \equiv 3(\bmod 4)$.