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 $R$ is a ring, $x\in R,$ and $I=(x).$ then the following are equivalent:
-There exists some $r\in R$ such that $y=xr$ for all $y\in I.$
-There is exactly one element in $I.$
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....)