Polynomials are irreducible in $\mathbb{Z}[x]$ if they are irreducible in $\mathbb{Z}/p\mathbb{Z}$, why p needs to be prime? The proof says we define the modulo function as the natural homomorphism,
$$ \bar\phi: \mathbb Z \to \mathbb Z / p\mathbb Z$$
Then if $h \in \mathbb Z[x]$ is reducible, the identity 
$$ \bar\phi(h) = \bar\phi(fg) = \bar\phi(f) \bar\phi(g) $$
proves $h (\text{mod}\ p)$ is also reducible in $\mathbb Z_p$
However, this proof tells nothing about $p$ being prime. And consider
$$ \bar\phi: \mathbb Z \to \mathbb Z / 4\mathbb Z $$
is also a homomorphism, defined by
$$ z \mapsto z + 4\mathbb Z$$

The question of reducibility in $R[X]$ is more complicated when $R$ is not a field, so we usually restrict our attention to fields.
For example, $5x+1=(2x+1)(3x+1)$ is reducible in $\mathbb{Z}/6\mathbb{Z}$.  When $p$ is not prime, reducibility is too common to be interesting.
