I proved this by taking cases for different remainders and using modular arithmetic, when the prime is $3$.However this method won't give a general proof for all primes.I was eager to get a proof for all primes $p$, but i couldn't get one.I have seen in Pythagorean triples that if both $a$ and $b$ are not divisible by $p$, $c=a^2 + b^2$ is also not, but how do i prove it?
Proving by contradiction may help...maybe induction. Also we can try proving for all numbers. of the form $6n+1$ and $6n-1$ so that it becomes evident for all primes.
The question changed and now is about proving that for all primes equivalent to $3 \bmod 4.$
Suppose $$p\equiv 3\mod 4$$ is a prime and $$a^2+b^2\equiv 0\mod p$$ holds.
$b\equiv 0\mod p$ implies $a\equiv 0\mod p$
If $b\ne 0\mod p$, then multiplying with $(b^{-1})^2$ turns the equation into $$u^2+1\equiv 0\mod p$$ so $$u^2\equiv -1\mod p$$
Hence $-1$ is a quadratic residue mod $p$, which is impossible for a prime $p$ with $p\equiv 3\mod 4$.