A Zariski Closed subset $W \subseteq A^n$ is called reducible if $W = > W_{1} \cup W_{2}$ where $W_{i} \nsubseteq W$ and $W_{i}$ closed.
Let $W \subseteq A^n$ be closed. Then $W$ is irreducible only if $I(W)$ is a prime ideal.
Sufficiency: Suppose $I(W)$ is not prime. Then $\exists f_{1}, f_{2} \notin I(W)$ such that $f_{1},f_{2} \in W$. Set $W_{1} = W \cap V (f_{1})$ and $W_{2} = W \cap V (f_{2})$.
As $f_{i} \notin I(W)$, $W \nsubseteq V (fi)$, and so $W_{i} \subsetneq W$. Now we must show that $W = W_{1} \cup W_{2}$. Let $a ∈ W$. Assume $a \notin W_{1}$. Then $f_{1}(a) \neq 0$, but $f_{1}(a)f_{2}(a) = 0$, so $f_{2}(a) = 0$, thus $a ∈ W_{2}$.
How can necessity be proved?
You have to prove that if $I(W)$ is prime, $W$ is irreducible.
Suppose $W=W_1\cup W_2$, and $W_1, W_2$ are closed. Then $I(W)=I(W_1)\cap I(W_2)$, a fortiori $I(W_1)\cdot I(W_2)\subset I(W)$. As $I(W)$ is prime, this implies one of $I(W_1), I(W_2)$ is contained in $I(W)$. Hence $V(I(W))$ is contained in one of $V(I(W_1)), V(I(W_2))$.. As all of $W, W_1, W_2$ are closed, we have that $W$ is contained on one of $W_1,W_2$, hence is equal to it. This proves $W$ is irreducible.