When we simplify this, we get:
\[a^2-p(a)=\left(p(b)\right)^2-b.\]We can say that $a\geq p(a)$, so the LHS will always be positive.
If $b$ has more than two prime factors, then we can say $b\geq p(b)\cdot \left(p(b)+1\right)$ which means that $b\geq \left(p(b)\right)^2$. This means that the RHS will be negative so it cannot ever equal the LHS.
If $b$ has only one prime factor, we can write it as $r^k$, where $k$ is a positive integer and $r$ is a prime number. This means that the RHS becomes:
\[r^2-r^k.\]In order for this to be positive, $k$ has to be $1$ meaning that $b=p$. When we set this equal to the LHS, we get:
\[a^2-p(a)=r^2-r,\]\[(a-r)(a+r)=p(a)-r.\]Since $a\geq p(a)$, we can say that $a+r>p(a)-r$. This means that in order for both sides of thsi equation to be equal, $a-r$ has to be $0$ meaning that $a=r$ or $a=b$.