Let $R$ be an integral domain. Assume $R$ is UFD, show $R$ is GCD.
I did not find proof anywhere except one in proofwiki, but unfortunately there is a crucial part which I do not understand. https://proofwiki.org/wiki/UFD_is_GCD_Domain
Proof: Let $x,y\in R\setminus \{0\}$. As $R$ is UFD, we can write $x=ux_1x_2...x_r$, $y=vy_1y_2...y_s$, $u,v,x_i,y_j\in R$.
If $\exists x_i\in\{x_1,...,x_r\},y_j\in\{y_1,...,y_s\}$ such that $x_i$ and $y_j$ are associate., then rearrange $\{x_1,...,x_r\}$,$\{y_1,...,y_s\}$ such that $x=u(x_1...x_t)x_{t+1}...x_r, y=v(y_1...y_t)y_{t+1}...y_{s}$ where $1\leq t\leq min(r,s)$ and $x_i,y_i$ are associate for all $i\leq t$ and $\not\exists i \in[t+1,r],j\in[t+1,s]$ such that $x_i,y_j$ are associate.
Let $d:=x_1...,x_t$ if such $t$ exists otherwise let $d:=1$.
Claim: $d$ is a greatest common divisor of $x$ and $y$. Certainly, $d|x$ and $d|y$. Let $f\in R\setminus \{0\}$ such that $f|x$ and $f|y$(i.e. $\exists w,z\in R\setminus\{0\}$ such that $x=fw,y=fz$). We need to show $f|d$.
We assume $f$ is not a unit otherwise $f|d$ and we are done. Hence assume $f$ is not a unit and assume for contradiction that $f$ does not divide d.
Then the author claims $f$ must contain in its prime factorisation a irreducible element which does not divide $d$.
Why should this be true? For example $\mathbb{Z}$ is a UFD and 4 does not divide 6 but all irreducible factors of 4, namely 2,-2, divide 6.
It's true that "$f$ does not divide $d$ implies there is an irreducible dividing $f$ that doesn't divide $d$" is a false statement.
However, your example does not take into account the full context, that $f$ divides $x,y$. If $4$ divides both $x$ and $y$, then both $2$'s in the factorization would have been grouped into $d$, and so $6$ would not be a valid option for $d$.
If all irreducible factors of $f$ appeared (separately, as associates) as a irreducible factors of $d$, then by the way $d$ was constructed, the factorization of $f$ (with multiplicities and all) would be listed in $d$'s factorization, and $f|d$, which we have assumed is not the case. Therefore there must be an irreducible factor of $f$ not associate to any irreducible in $d$'s factorization.