Let pa+a4=b2 for some positive integer b. Then we have
pa=b2−a4=(b+a2)(b−a2).
Hence both b+a2 and b−a2 are powers of p.
Let b−a2=px for some integer x. Then b+a2=pa−x and a−x>x. Therefore we have
2a2=(b+a2)−(b−a2)=pa−x−px=px(pa−2x−1).
We shall consider two cases according to whether p=2 or p=2. We let vp(m) denote the p-adic valuation of m.
Case 1 (p=2): In this case,
a2=2x=1(2a−2x−1)=22v2(a)(2a−2x−1),
where the second equality comes from gcd(2,2a−2x−1)=1. So, 2a−2x−1 is a square.
If v2(a)>0, the 2a−2x is also a square. So, 2a−2x−1=0 and a=0 which is a contradiction.
If v2(a)=0, then x=1, and a2=2a−2−1. If a≥4, the right hand side is congruent to 3 modulo 4, thus cannot be a square. It is easy to see that a=1,2,3 do not satisfy this condition.
Therefore, we do not get any solutions in this case.
Case 2 (p=2): In this case, we have 2vp(a)=x. Let m=vp(a). Then we have a2=p2m⋅n2 for some integer n≥1. So, 2n2=pa−2x−1=ppm⋅n−4m−1.
We consider two subcases.
Subcase 2-1 (p≥5): By induction one can easily prove that pm≥5m>4m for all m. Then we have
2n2+1=ppm⋅n−4m>ppm⋅n−pm≥55m⋅(n−1)≥5n−1
But by induction, one can easily prove that 5n−1>2n2+1 for all n≥3. Therefore, we conclude that n=1 or 2. If n=1 or 2, then p=3, which is a contradiction. So there are no solutions in this subcase.
Subcase 2-2 (p=3): Then we have 2n2+1=33m⋅n−4m. If m≥2, one can easily prove by induction that 3m>4m. Then we have
2n2+1=33m⋅n−4m>33m⋅(n−1)≥39(n−1)
By induction, one can easily prove that 39(n−1)>2n2+1 for all n≥2. Therefore, we conclude that n=1. Then we have 2⋅12+1=33m−4m hence 3m−4m=1. The only solution of this equation is m=2 in which case we have a=3m⋅n=32⋅1=9.
If m≤1, then there are two possible cases: m=0 or m=1.
If m=1, then we have 2n2+1=33n−4. By induction, can see that 33n−4>2n2+1 for all n≥3. By checking n=1,2, we only get n=2 as a solution, this gives a=3m⋅n=31⋅2=6.
If m=0, then we have 2n2+1=3n. By induction, can see that 3n>2n2+1 for n≥3. Checking n=1,2, we find the solution a=30⋅1=1 and 30⋅2=2. Therefore, (a,p)=(1,3),(2,3),(6,3),(9,3) are all possible solutions.