Zev's and Georges' answers are complete. I would like to give you a deeper sight. This is a guide line through easy claims that you should be able to prove on your own. Let $A$, $B$ be two rings.
Every ideal of $A \times B$ is of the form $I \times J$, for unique ideals $I \subseteq A$ and $J \subseteq B$. If this is the case, $(A \times B) / (I \times J) \simeq (A / I) \times (B / J)$.
$A \times B$ is a domain iff ($A$ is a domain and $B = 0$) or ($B$ is a domain and $A = 0$).
Every prime ideal of $A \times B$ is of the form $\mathfrak{p} \times B$, for some prime ideal $\mathfrak{p}$ of $A$, or $A \times \mathfrak{q}$, for some prime ideal $\mathfrak{q}$ of $B$.
The localization $(A \times B)_{\mathfrak{p} \times B}$ is isomorphic to $A_\mathfrak{p}$, for every prime ideal $\mathfrak{p}$ of $A$.
This proves that if a ring $R$ is the product of a finite number ($\geq 2$) of integral domains, then $R$ is not a domain but every its localization at primes is a domain.
This has also a geometric interpretation, if you know Zariski topology on the prime spectrum of a ring. From (3) you have a homeomorphism $\mathrm{Spec} (A \times B) \simeq \mathrm{Spec} A \coprod \mathrm{Spec} B$, then $\mathrm{Spec} (A \times B)$ is disconnected and is locally the spectrum of a domain, if $A$ and $B$ are domains.
Firstly, the statement should require that $(a)$ contains a nonzero prime ideal, since all ideals contain $(0)$, which is prime, since you've specified that our ring, call it $R$ is a domain.
First note that $a$ is prime if and only if the ideal $(a)$ is prime. Thus if we have $\newcommand\pp{\mathfrak{p}}\pp\subseteq (a)$, then it suffices to prove that $a\in \pp$, since then $(a)=\pp$, so $(a)$ is prime.
Thus if $af\in \pp$ with $f\not\in\pp$, then $a\in\pp$, and $a$ is prime. Thus if $a$ is not prime, then if $ar\in \pp$, then $r\in\pp$. However, since every element of $\pp$ is of the form $ar$ for some $r\in R$, this tells us that $a\pp=\pp$.
Now since $a\ne 0$ and $a$ is a nonunit, and $\pp\ne R$ is a proper ideal, $a\pp$ contains no irreducibles (if $a\pi \in a\pp$, then since $a,\pi$ are both nonunits, $a\pi$ is not irreducible). Hence since $a\pp=\pp$, $\pp$ contains no irreducibles. However any nonzero prime ideal in a factorization domain contains an irreducible (let $x=\prod_i \pi_i\ne 0\in \pp$, then if none of the irreducible $\pi_i$s was in $\pp$, then since $\pp$ is prime, their product, $x$ wouldn't be in $\pp$ either, contradiction). Thus we have a contradiction, so we've proved our desired claim.
Note actually that we've proven the stronger claim:
Let $R$ be a factorization domain, then if $0\subsetneq \pp \subseteq (a)\subsetneq R$, with $\pp$ prime, then $\pp=(a)$, so $a$ is prime.
That is, we don't need that $a$ is irreducible, just that it is nonzero and not a unit.
Edit: We can do better. An argument at the beginning of chapter 10 in Eisenbud's Commutative Algebra reminded me that we don't need that $R$ is a factorization domain, just that it is a domain. Instead,
once we have $a\pp=\pp$, we apply Nakayama's lemma to conclude that $(1-ax)\pp=0$, for some $ax\in (a)$. However, since $\pp\ne 0$ and $R$ is a domain, we have $1-ax=0$, but we also have that $(a)$ is proper, so $1\not \in (a)$, so $1-ax\ne 0$. This is a contradiction. Thus, in fact, we have
Let $R$ be a domain. If $0\subsetneq \pp \subseteq (a) \subsetneq R$, with $\pp$ prime, then $\pp=(a)$, so $a$ is prime.
Best Answer
While it is true that, for all $y\in I,$ there is some $r\in R$ such that $y=xr,$ it does not have to be the same $r$ for every $y.$ In fact, the only way it can be the same for every $y\in I$ is if there is only one $y\in I$, which means that $x=0$.
More formally, we have the following:
Suppose $y_1,y_2\in I.$ If some $r\in R$ exists as described in the first statement, then $y_1=xr=y_2,$ meaning that all elements of $I$ are equal, which (since ideals are never empty) means that $I$ has one element. Now, if $I$ has exactly one element, it must be $x$ by definition of $I,$ but it must be $0$ since $I$ is an additive subgroup of $R$ (as all ideals of $R$ are), and so $x=0.$
I leave the last implication to you.
You cannot conclude that $b$ is an irreducible element, because it isn't necessarily true. Consider $R=\Bbb Z,$ $x=3,$ $a=15,$ and $b=4$. Now, $I=(x)$ is a prime ideal, and both $a,ab\in I,$ but $b$ is not irreducible.
Now, on to the result that you're trying to prove. Instead, suppose that $x=ab$ for some $a,b\in R.$ Show that $a$ or $b$ must be a unit, and so $x$ is irreducible. (Hint: Since $ab=x\in I$ and $I$ is a prime ideal, then....)