Example 3 Find all positive integer pairs $(a, b)$ such that $a \neq b, a+b^{2}$ is a square of a prime number, and $a+b^{2} \mid a^{2}+b$.

Translate the above text into English, please retain the original text's line breaks and format, and output the translation result directly.
Solution: From $a+b^{2}>0$ we get $a>b$, and $a+b^{2}|a^{2}+b, a+b^{2}| a^{2}+a b^{2} \Rightarrow$ $a+b^{2} | b(a b-1)$ (1).
Let $a+b^{2}=p^{k}$, if $(a, b)>1$, then $(a, b)=p^{r}(r \geqslant 1)$, let $a=a_{1} p^{r}, b=b_{1} p^{r}, (a_{1}, b_{1})=1$, substituting into (1) we get $a_{1}+b_{1}^{2} p^{r}|b_{1}(a_{1} b_{1} p^{2 r}-1) \Leftrightarrow a_{1}+b_{1}^{2} p^{r}| a_{1} b_{1} p^{2 r}-1$, since $a_{1} p^{r}+b_{1}^{2} p^{2 r}=p^{k}$, so $a_{1}+b_{1}^{2} p^{r}=p^{k-r}$, thus $p|a_{1}+b_{1}^{2} p^{r}, p| a_{1} b_{1} p^{2 r}-1$ contradiction! Hence $(a, b)=1, (a+b^{2}, b)=1$. From (1) $a+b^{2} | a b-1$.

Since $a+b^{2} | a b+b^{3}$, so $a+b^{2} | b^{3}+1=(b+1)(b^{2}-b+1)$, since $(b+1, b^{2}-b+1)=(b+1,3)=3$ or 1.

If $p \neq 3$, from $p^{k}=a+b^{2} |(b+1)(b^{2}-b+1)$ we get: $p^{k} | b+1$ or $p^{k} | b^{2}-b+1$,

but $p^{k}=a+b^{2}>b+1, p^{k}=a+b^{2}>b^{2}-b+1$, contradiction!
Hence $p=3, a+b^{2}=3^{k}, 3^{k} |(b+1)(b^{2}-b+1)$, thus we have $\left\{\begin{array}{l}b+1=3 t_{1}, \\ b^{2}-b+1=3^{k-1} t_{2}\end{array}\right.$, where $3 \backslash t_{1}$

or $\left\{\begin{array}{l}b+1=3^{k-1} t_{1}, \\ b^{2}-b+1=3 t_{2} .\end{array}\right.$ (where $3 \backslash t_{2}$)
For (2), substituting $b=3 t_{1}-1$ into $b^{2}-b+1=9 t_{1}^{2}-$ $9 t_{1}+3=3^{k-1} t_{2}$ we get $3 t_{1}^{2}-3 t_{1}+1=3^{k-2} t_{2}$,
since $3 \times 3 t_{1}^{2}-3 t_{1}+1$, so $k=2, a+b^{2}=9$,
so $b^{2}+b \leqslant 8, b=2, a=5$;
For (3), from $b^{2}+b+1 \leqslant b^{2}+a=3^{k} \leqslant 3^{k} t_{1}=3 b+3$ we get $(b-1)^{2} \leqslant 3, b=2, k=2, a=5$;
In summary, there is only one solution $(5,2)$.