[guided]Uniqueness of factorization is the deeper part of the argument, and it hinges on a property that does not hold in all integral domains: in a PID, every irreducible element is prime.
**Why is irreducible the same as prime in $k[x]$?** Let $p \in k[x]$ be irreducible. We want to show that $p$ is prime, i.e., the ideal $(p)$ is a prime ideal. In a PID, the ideal $(p)$ is nonzero (since $p$ is not zero) and proper (since $p$ is not a unit). We claim $(p)$ is maximal. Suppose $(p) \subset (d)$ for some $d \in k[x]$. Then $p = d \cdot q$ for some $q \in k[x]$. Since $p$ is irreducible, either $d \in k^\times$ (so $(d) = k[x]$) or $q \in k^\times$ (so $(d) = (p)$). Hence $(p)$ is maximal. In a commutative ring, every maximal ideal is prime, so $(p)$ is prime and $p$ is a prime element.
This is exactly where the PID hypothesis is consumed. In a ring like $\mathbb{Z}[\sqrt{-5}]$, which is not a PID, irreducible elements need not be prime, and unique factorization fails.
**Uniqueness by induction.** Suppose $q_1 q_2 \cdots q_s = r_1 r_2 \cdots r_t$ where all $q_i, r_j$ are irreducible in $k[x]$. We induct on $s$.
*Base case ($s = 1$):* Then $q_1 = r_1 \cdots r_t$. Since $q_1$ is irreducible and each $r_j$ is a non-unit, we must have $t = 1$ and $q_1 = r_1$ (up to a unit, but if both sides have the same product, the unit is forced).
*Inductive step ($s \ge 2$):* The irreducible $q_1$ divides the product $r_1 r_2 \cdots r_t$. Since $q_1$ is prime, $q_1 \mid r_j$ for some $j \in \{1, \dots, t\}$. Reindex so that $j = 1$. Since $r_1$ is irreducible and $q_1 \mid r_1$ with $q_1$ not a unit, we must have $r_1 = u_1 q_1$ for some $u_1 \in k^\times$ (the only divisors of an irreducible are units and associates). Now cancel $q_1$: since $k[x]$ is an integral domain, $q_1 q_2 \cdots q_s = u_1 q_1 r_2 \cdots r_t$ implies $q_2 \cdots q_s = u_1 r_2 \cdots r_t$. Absorbing the unit $u_1$ into $r_2$ (replacing $r_2$ by $u_1 r_2$, which remains irreducible since units do not affect irreducibility), we apply the inductive hypothesis to conclude $s - 1 = t - 1$ and, after reordering, $q_i$ is an associate of $r_i$ for each $i \ge 2$. Combined with $r_1 = u_1 q_1$, the two factorizations agree up to reordering and unit multiples.[/guided]