I think the question is easy:
First, if $x^2+1$ is irreducible in $\mathbb Z_p[x]$, then $x^2+1\equiv 0\pmod p$ has no solution, as you observed, so no integer $a$ satisfies $a^2\equiv -1\pmod p$, i.e. the quadratic residue $(\dfrac{-1}{p})=-1.$ Hence, by Euler's criterion, we find that $p\equiv 3\pmod4,$ which is exactly equivalent with your other condition.
Second, if $a^2\equiv-1\pmod p,$ then we see that $$\mathbb Z[i]/(p)=\mathbb (Z[x]/(x^2+1))/(p)=\mathbb Z_p[x]/(x^2+1)=\mathbb Z_p[x]/((x-a)(x+a))=\mathbb Z_p\oplus\mathbb Z_p$$ is not an integral domain, i.e. $p$ is not a prime in $\mathbb Z[x].$
Hope this helps.
P.S. For the last isomorphism, see Chinese Remainder Theorem.
P.P.S.This is a special case of Dedekind's theorem.
P.P.P.S.If you know not about the commutative algebra, just employ of the wonderful proof by tetori instead, in the second part of the proof.