Why $\langle x^2+1\rangle$ is not prime in $\mathbb{Z}_2[x]$? I am reading ring theory (a beginner) and I stumbled upon a problem which I can't understand 

The ideal $\langle x^2+1\rangle$ is not prime in $\mathbb{Z}_2[x]$, since it contains $(x+1)^2=x^2+2x+1=x^2+1$ , but does not contain $x+1$ .

$\langle x^2+1\rangle$ denotes the principal ideal generated by $x^2+1$ i.e. $$\langle x^2+1\rangle=\{f(x)(x^2+1)\mid f(x)\subset \mathbb{R}[x]\}$$ 
$\mathbb{R}[x]$ denotes the ring of polynomials with real coefficients. 
My doubt:
How can $x^2+1+2x$ be written in the form $f(x)(x^2+1)\mid f(x)\subset \mathbb{R}[x]$ ?

You're comparing apples and oranges. The rings $\mathbb{Z}_2$ and $\mathbb{R}$ are very different and the polynomial $x^2+1$ has different behavior in them and there's no contradiction, because
$$
x^2+1\in\mathbb{Z}_2[x]
$$
and
$$
x^2+1\in\mathbb{R}[x]
$$
are different objects that live in distinct sets.
So it can very well happen that one is reducible and the other one isn't. Indeed so it happens; in $\mathbb{Z}_2[x]$ we have
$$
x^2+1=(x+1)^2
$$
whereas $x^2+1\in\mathbb{R}[x]$ is irreducible.
