Proving that if $p^2 = a^2 + 2b^2$ then also $p$ can be written in form $a^2 +2b^2$ I'm high school student, and this problem has bothered me for about 2 weeks now. I don't necessarily need a solution, but for example mentioning a helpful theorem or property that could help me to prove this would be nice.

If $p^2$ can be written in form $a^2 + 2b^2$ show that also $p$ can be written in same form, where $p$ is a prime number, and $a,b\in\mathbb{Z},b\neq0$. 

This far I've tried pretty much everything that comes into my imagination. I can assume $p$ is odd since $2^2$ cannot be written in desired form. From this I can conclude $a$ must also be odd. From this I can also substitute $2z + 1 = p$ to left hand side of this equation which I obtained from assumption ($p^2 = a^2 + 2b^2$). The left hand side ($p^2$) looks like this when I expand square: $4z^2 + 4z + 1$. From here I've subtracted $4z^2$ and $2z$ from both sides of equation, just leaving $2z + 1= p$ on the left side. The right hand side would look like this: $a^2 + 2b^2 - 4z^2 - 2z$, and I don't know how to prove something in that mess of terms forms a perfect square.
This problem started to seem even more mystic for me once I investigated a few examples. To my surprise there doesn't appear any obvious relations between $a$ and $b$ for $p$ and for $p^2$. Could it be so that my approach is entirely wrong, and it's not possible to derive $a$ and $b$ for $p$ from those numbers for $p^2$?
I also tried to find relations by writing an equation based on this so that $p$ was constant and $a$ and $b$ were variables. Then I investigated if curve crossed any point that had integer coordinates and then compared such points for different constants, especially for different $p^2$ and $p$. I used also implicit differentiation to see if there is any harmony on their placement on ellipse (curve is always ellipse of same shape, but size of it differs depending on constant) but so far I haven't found anything. 
I will add I'm quite unfamiliar with math, so I'd appreciate it if advice would be understandable for person who does not have a very deep knowledge of math.
 A: Let's assume that $p$ is odd and use a bit of algebraic number theory.
Consider the field $\mathbb{Q}(\sqrt{-2})$, which has the ring of integers $\mathbb{Z}[-2]$. This is a Dedekind domain, so ideals factor uniquely, and so a PID.
By the question we have $(p^2)=(p)^2=(a^2+2b^2)$ and we want $(p)=(c^2+2d^2)$, as then have $p=u(c^2+2d^2)$ for some unit $u$ (the only units in $\mathbb{Z}[-2]$ are $\pm 1$, and by sign, $u=1$).
It's proven (c.f. Ireland and Rosen, page 190) that $(p)$ splits up into a product of one or two prime ideals in one of three ways. This depends on two conditions on $p$. 
(Let $P,P'$ be distinct prime ideals throughout).


*

*For finitely many $p$  (condition: $p\mid -8$, $-8$ being the discriminant of the field), $(p)=P^2$. But this only concerns $p=2$ so we move on to cases where $p \not \mid -8$.

*If $x^2=-2 \text{ mod }p$ is soluble in $\mathbb{Z}$, then $(p)=PP'$. $\mathbb{Z}[-2]$ is a a PID so $(p)=(x)(y)=(xy)$ for $x \ne y$, and have $p=uxy=\pm xy$. Necessarily $x=\bar{y}=c+d\sqrt{-2}$ and hence the result.

*If not soluble, then $(p)=P$, in which case your result would not hold. But if $(p)$ is prime, $p$ is prime in $\mathbb{Z}[\sqrt{-2}]$, then $p^2=(a+\sqrt{-2}b)(a-\sqrt{-2}b)$ implies that $(a+\sqrt{-2}b),(a-\sqrt{-2}b)$ are prime. But then $a=p,b=0$ by unique factorisation.
A: Here's an elementary proof.
From $p^2=a^2+2b^2$, we have $2b^2=(p-a)(p+a)$.  Since $b\not=0$, we have $\gcd(a,b)=1$ and consequently $\gcd(p-a,p+a)=2$.  Let's write $m=(p-a)/2$ and $n=(p+a)/2$, so that $\gcd(m,n)=1$ and $mn=2\beta^2$ where $\beta=b/2$.  (It's easy to see that $b$ must be even.)
Without loss of generality (since $a$ can be either positive or negative), we can assume that $m$ is even.  But since $\gcd(m,n)=1$, we must now have $m=2r^2$ and $n=s^2$, with $\gcd(2r,s)=1$ -- i.e., each prime factor of $\beta$ belongs entirely to either $m$ or $n$.  So we now have
$$m={p-a\over2}=2r^2$$
and
$$n={p+a\over2}=s^2$$
from which it follows that
$$p=s^2+2r^2$$
