Just follow your nose; let $d:=\gcd(a,b)$ so that $a=du$ and $b=dv$ with $u$ and $v$ coprime. Then
$$b^a=(dv)^{du}=((dv)^u)^d
\qquad\text{ and }\qquad
a^{b^2}=(du)^{d^2v^2}=((du)^{dv^2})^d,$$
from which it follows that $(dv)^u=(du)^{dv^2}$. Because $u$ and $v$ are coprime we either have $u=1$ or $v=1$.
If $u=1$ then $dv=d^{dv^2}$, and so $v=d^{dv^2-1}$ from which it quickly follows that also $v=d=1$ and hence $a=b=1$.
If $v=1$ then $d^u=(du)^d$ from which it follows that $u^d=d^{u-d}$, and in particular $u\geq d$. Let $c:=\gcd(d,u)$ so that $d=ce$ and $u=cw$ with $e$ and $w$ coprime and $w\geq e$. Then
$$u^d=(cw)^{ce}=((cw)^e)^c
\qquad\text{ and }\qquad
d^{u-d}=(ce)^{cw-ce}=((ce)^{w-e})^c,$$
from which it follows that $(cw)^e=(ce)^{w-e}$. As $e$ and $w$ are coprime and $w\geq e$ it follows that $e=1$, so
$$cw=c^{w-1},$$
and hence $w=c^{w-2}$, from which it quickly follows that $w\leq4$. We check these few cases:
- If $w=1$ then $c=d=1$ which leads to $a=b=1$.
- If $w=2$ then $u=2d$ and hence $a=2b^2$, and plugging this in shows that
$$b^{2b^2}=(2b^2)^{b^2}=2^{b^2}b^{2b^2},$$
contradicting the fact that $b$ is a positive integer.
- If $w=3$ then $c=d=3$ which leads to $a=27$ and $b=3$.
- If $w=4$ then $c=d=2$ which leads to $a=16$ and $b=2$.