I'm not sure that you are understanding the concept of a prime ideal correctly. A prime ideal is a proper ideal $I$ such that whenever $a,b\in R$ and $ab\in I$ one has either $a\in I$ or $b\in I$ already. So, in your case, both $a$ and $b$ are in $(2)$ and this ideal fits the definition perfectly.
I am assuming, based on your statement, that you are under the misconception that a prime ideal is an ideal $I$ such that whenever $ab\in I$ one has $a\not\in I$ and $b\not\in I$ (in other words, exactly the negation of the correct definition). Actually, here's the intuition as to why the definition is as it is: a prime number in $\mathbb{Z}$ is a number $p\ne 1$ so that whenever $p|ab$ one has $p|a$ or $p|b$. This translates naturally to the definition that $ab\in(p)$ implies $a\in(p)$ or $b\in(p)$. (This is for $\mathbb{Z}$, which is a principal ideal domain in which all ideals are generated by one element, and so all ideals are of the form $(n)$ for some $n$.)
This answer may provide further insight into the definition of a prime ideal: Motivation behind the definition of Prime Ideal