A little background:
Today I saw an answer to a question, in the answer José Carlos Santos said that the roots of $x^5-1$ are $1$, $e^{\pm\frac{2\pi i}5}$, and $e^{\pm\frac{4\pi i}5}$. afterwards he claimed that $$x^5-1=(x-1)\left(x-e^{\frac{2\pi i}5}\right)\left(x-e^{\frac{-2\pi i}5}\right)\left(x-e^{\frac{4\pi i}5}\right)\left(x-e^{\frac{-4\pi i}5}\right)$$this can be checked to be true, i can also see that this method( multiply $(x-$the root) for all roots)is not always true, any function divide by $x$ will have the $x=0$ be undefined, and constructing expression like this create a polynomial hence $x=0$ will exists.
my question is under what condition this method works? and why in those conditions?