Solution 1:

Note that $K[x_1,x_2,\dots]=\bigcup_{n\in \Bbb N}K[x_1,x_2,\dots,x_n]$. I'm going to denote these rings in the union by $R_n$ to save typing time.

To see that an irreducible $p$ of $R_n$ is irreducible in $R_m$ for $m\geq n$, suppose you have an equation $p=ab$ where $a,b\in R_m$. By evaluating $x_1,\dots, x_n$ all at 1, the variables in $p$ disappear, and you get an equation $\lambda=\overline{ab}\in K[x_{n+1}\dots, x_m]$ where $\lambda\in K$. This is a contradiction unless $a$ and $b$ already fell in $R_n$ in the first place, so that they had no variables above $x_n$. But you already know that in $R_n$, one of $a$ or $b$ must be a unit, so $p$ is irreducible in $R_m$ as well. So between the rings, primes stay prime and irreducibles stay irreducible.

This allows you to conclude that an element has a prime factorization in the first place.

Then you can argue that any two factorizations of a single element into primes must consist of elements in a common $K[x_1,\dots, x_m]$, which will force the factorizations to be equivalent.

Solution 2:

They key idea is that each successive polynomial ring extension $\,D\subset D[x]\,$ is factorization inert, i.e. the ring extension introduces no new factorizations, i.e. if $\, 0\ne d\ \in D\,$ factors in $\,D[x]\,$ as $\,d = ab\,$ for $\, a,b\in D[x]\,$ then $\,a,b\in D.\,$ From this one easily deduces that the requisite factorization properties extend to the ascending union $\,K[x_1,x_2,\cdots\,],$ and the same ideas work for arbitrary inert extensions.

Remark $\ $ Paul Cohn introduced the idea of inert extensions when studying Bezout rings. Cohn proved that every gcd domain can be inertly embedded in a Bezout domain, and every UFD can be inertly embedded in a PID. There are a few variations on the notion of inertness that prove useful when studying the relationship between factorizations in base and extension rings, e.g. a weaker form where $\, d = ab\,\Rightarrow\, au, b/u\in D,\,$ for some unit $\,u\,$ in the extension ring.