Missing template due to originally being placed in different forum

Hi, a friend of mine gave me a math problem which I've spent hours trying to find different methods to solve. But none of them work and I'm now out of ideas. The problem goes like this:

So for example, ##17^2 = 1^2 + 2(12^2) ⇒ 17 = 3^2 + 2(2^2) ## or ## 3^2 = 1^2 + 2(2^2) ⇒ 3 = 1^2 + 2(1^2)##
I also realized that this statement that we have to prove might also hold for all non-prime numbers as well. I found several examples that show that this is true:
##9^2 = 3^2 + 2(6^2) ⇒ 9 = 1^2 + 2(2^2)## or ## 12^2 = 4^2 + 2(8^2) ⇒ 12 = 2^2 + 2(2^2) ##
So perhaps the information that 'p' is a prime plays no role whatsoever in the final proof. However, I'm not really sure about this.
I've tried many methods so far, from indirect proofs (contradiction & contrapostive) to direct proofs, but none of them work. I've also looked at modular arithmetic, but that's getting nowhere. I'm really desperate for help at this moment. Any inputs from you guys are greatly appreciated, cuz my friend and I have been stuck for weeks on this question!
Thanks a lot in advance!

Looking for possible values of p^{2}=a^{2}+2b^{2} (without the prime constraint), I found a general class of 9n^{2} = n^{2} + 2 (2n)^{2}, but only the first value in this class gives a prime p.

All classes should be found like that:
(n-1)^{2} + 4*n = (n+1)^{2} where 2n has to be a square.
(n-2)^{2} + 8*n = (n+2)^{2} where 8n has to be a square.
...

How to prove that those values then have a similar sum without the square (or, equivalently, fall into one of those classes as well)? That's the interesting problem.

Edit: that pattern leads to many values which do not allow to get prime numbers. Only odd squares and twice square roots can potentially lead to primes (e. g. 8=2*4, 9, 18=2*9, ...). I guess that is a key observation.

Edit2: Indeed it is, and another step leads to the proof. It is important to require p to be prime for that proof, although I don't have a counterexample for a non-prime right now.

Edit3: and here is the counterexample for non-prime numbers: 15^{2} = 5^{2} + 2*10^{2}, but there is no possible sum for 15=m^{2}+2n^{2}.

Edit 4: There is a very compact proof. A nice puzzle :).