It is a known fact that if $R$ is a UFD, then $R[X_1,X_2,\dots]$ is also a UFD, but there is a subtlety that is making me uncomfortable.
The standard approach essentially goes something along the lines of...let $f$ be a polynomial, so it only involves finitely many variables, say up to $X_1,\dots,X_n$. Then since $R[X_1,\dots,X_n]$ is a UFD, $f$ has a factorization into irreducibles. Then $f$ cannot have a factorization involving indeterminates $X_N$ not in $R[X_1,\dots,X_n]$. If it did, then $f$ would have two factorizations in the UFD $R[X_1,\dots,X_n,\dots, X_N]$, a contradiction.
This seems to assume that the prime factorization in $R[X_1,\dots,X_n]$ is still a prime factorization in $R[X_1,\dots,X_n,\dots,X_N]$. But how can you see that irreducibles in $R[X_1,\dots,X_n]$ are still irreducibles in $R[X_1,\dots,X_m]$ for $m>n$? This does not seem obvious.
Let $R_k=R[X_1,\dots,X_k]$. The explanantion I found is this: Suppose $p\in R[X_1,\dots,X_n]$ is irreducible in $R_n$. Suppose $p=ab$ for $a,b\in R_m$. Evaluating $X_1,\dots,X_n$ at $1$, you get $$ \bar{p}=\overline{ab}\in R[X_{n+1},\dots,X_m] $$ But $\bar{p}\in R$, which implies that $a$ and $b$ do not involve any variables $X_{n+1},\dots,X_m$. So $a,b\in R_n$, and thus one is a unit, hence a unit in $R_m$.
The part I don't follow is how evaluation at $1$, implies $a$ and $b$ do not have indeterminates other than $X_1,\dots,X_n$. Isn't it possible that some of the higher indexed indeterminates disappear when you evaluate? Suppose for instance $p\in R_1$, and $a\in R_2$ is $a=-X_1X_2+X_2$. Then evaluting at $1$ gives $\bar{a}=0$ so we may not get the desired contradiction since $\overline{ab}=0\in R$?