<s>[INST] Non unique factorization in $\mathbb{Z}_5$ 
Prove $3X^3+4X^2+3=(X+2)^2(3X+2)=(X+2)(X+4)(3X+1)$ in $\mathbb{Z}_5$.

I see that $2$ is a root (since $-24+16+3=-5$) , then $3X^3+4X^2+3=(X+2)(3X^2)$, and also $-4$ (since -$64\cdot3+16\cdot4+3=-125$) and although $x=-1/3$ is not in $\mathbb{Z}_5$, because it also works as a root then $3x+1$ is a nother factor. 
Then it should be $3X^3+4X^2+3=(X+2)(X+4)(3X+1)$ but the product of the right side gives $3X^3+24X^2+30X+8=3X^3+4X^2+3+5(4X^2+6X^2+1)=3X^3+4X^2+3.$
But why is it $3X^3+4X^2+3=(X+2)^2(3X+2)$? It seems $(X+2)^2(3X+2)=(X^2+2X+4)(3X+2)=3X^4+8X^2+10X+8=3X^4+3X^2+3+5(X+2X+1)=3X^4+3X^2+3$ which is not the initial polynomial.
Also, $\mathbb{Z}_5$ is UFC domain, wouldn't the double factorization imply a contradiction?
 [/INST] Factorization is only unique up to associates; e.g. over the reals, we can factor $4x^2 - 1$ in many different ways
$$ 4x^2 - 1 = (2x-1)(2x+1) = 4\left(x - \frac{1}{2}\right)\left(x + \frac{1}{2}\right) = (4x-2)\left(x + \frac{1}{2} \right)$$
In $k[x]$, we most commonly normalize by factoring out an overall unit so as to make the nonconstant factors monic polynomials; the individual factors of this form are unique. (the ordering is not)
Doing so, you would further factor
$$ (X+2)^2 (3X+2) = 3 (X+2)^2 (X+4) $$
$$ (X+2)(X+4) (3X+1) = 3 (X+2)(X+4)(X+2) $$
and we can see that, in both cases, the factorizations really do have the same factors.
In other words, what you were overlooking was:


*

*$3X+2$ and $X+4$ are associates

*$3X+1$ and $X+2$ are associates

</s>