When the condition is satisfied, there exists a non-negative integer n such that ap4+2p3+2p2+1=n2 and then
(a−p2−2p−1)p4=n2−(p3+p2+1)2=(n+p3+p2+1)(n−p3−p2−1)(∗)
holds. If we assume that both n+p3+p2+1 and n−p3−p2−1 are divisible by p, then n+1≡0≡n−1(modp), leading to 2≡0(modp), which contradicts the assumption that p is an odd prime. Therefore, at least one of n+p3+p2+1,n−p3−p2−1 is not divisible by p. Since the left hand side of (*) is divisible by p4, one of n+p3+p2+1,n−p3−p2−1 is divisible by p4.
In the case n+p3+p2+1 is divisible by p4, there exists a positive integer k such that n=kp4−p3−p2−1. By substituting this into (*), we obtain (a−p2−2p−1)p4=kp4(kp4−2p3−2p2−2), hence a=p2+2p+1+k(kp4−2p3−2p2−2). If k≥2, we have
a>4(p4−p3−p2−1)=4p4(1−p1−p21−p41)≥4p4(1−31−91−811)>p4
which contradicts a<p4. If k=1, then a=p4−2p3−p2+2p−1=(p2−p−1)2−2. In this case, by p≥3 we get 2≤p2−p−1<p2 and then 1≤a<p4. Therefore, the number of pairs (p,a) satisfying the condition is equal to the number of odd prime p such that (p2−p−1)2−2≤2024, and there exist three such primes p=3,5,7.
In the case n−p3−p2−1 is divisible by p4, there exists a non-negative integer k such that n=kp4+p3+p2+1. By substituting this to (*), we obtain (a−p2−2p−1)p4=kp4(kp4+2p3+2p2+2), hence a=p2+2p+1+k(kp4+2p3+2p2+2). If k≥1, then we have a>p4 which contradicts a<p4. If k=0, then we have a=p2+2p+1=(p+1)2. In this case, by p≥3 we get 1<(p+1)2<(p2)2=p4 and then 1≤a<p4. Therefore, the number of pairs (p,a) satisfying the condition is equal to the number of odd prime p such that (p+1)2≤2024, and there exist 13 such primes p=3,5,7,11,13,17,19,23,29,31,37,41,43.
We have proved that the total number of pairs (p,a) satisfying the condition is 3+13=16.