Disclaimer: there are other proofs of this, among which one can find a proof with quadratic forms, infinite descent and etc. The following is easier for me.
You must prove that a prime $\;p\;$ is the sum of two squares iff $\;p=1\pmod 4\;$. For this, we first show that $\;-1\;$ is a square $\;\pmod p\iff p=1\pmod 4\;$ :
Let us look at the (cyclic) multiplicative group of the integers modulo $\;p\;$ , i.e. $\;\Bbb F_p^*:=\Bbb F\setminus\{0\}\;$ .
== If $\;x^2=-1\pmod p\;$ has a solution then $\;x^4=1\pmod p\;$ . But we also know (Fermat's Little Theorem) that $\;x^{p-1}=1\pmod p\;$ (since clearly $\;x\neq 0\pmod p\;$ , and from Lagrange's Theorem we get that
$$\;4\mid (p-1)\iff p=1\pmod 4\;$$
The other direction I leave to you (use that a cyclic finite group has one unique subgroup of any order dividing the group's order).
From the above if follows that if $\;p=1\pmod 4\;$ then $\;p\mid m^2+1\;$ for some integer $\;m\;$ (which can also be considered as an element in $\;\Bbb F_p^*\;$ is wanted).
But $\;\;m^2+1=(m-i)(m+i)\;,\;\;i=\sqrt{-1}=\;$ the square root of $\;-1\;$ we proved above to exist. But $\;p\;$ doesn't divide either of $\;m-i\,,\,\,m+i\;$ (why? Look at the imaginary parts and, of course, the fact that the gaussian integers are a Unique Factorization Domain (why?)), so $\;p\;$ cannot be prime in $\;\Bbb Z[i]\;$ , and since the norm on this ring is multiplicative and $\;\mathcal N(p)=p^2\;$ , we must have a factorization in two elements with the same norm:
$$p=(x+iy)(x-iy)=x^2+y^2\;,\;\;\text{and we're done}$$
Now, what the above has to do with your question?? Well, if $\;p\;$ is not a prime $\;=1\pmod 4\;$ then it is not a sum of squares and thus, from the last part of the proof above, it must be prime in $\;Z[i]\;$ as its norm still is the square of a prime in $\;\Bbb Z\;$ !