Let's consider $$f(x) = \frac{(x-1)(x-2)(x-3)}{x^2-3x+2}$$ with definition $D_{f} = \mathbb{R} \setminus \lbrace 1, 2 \rbrace$. This means we are allowed to set $x$ to every value of $\mathbb{R}$ except one and two. However we can transform the function so that those get valid:
$$u_{0} = x^2-3x+2 = \frac{3}{2} \pm \sqrt{\frac{3}{2}-2} = \frac{3}{2} \pm \frac{1}{2}$$ we can factorize $f(x)$ as $$f(x) = \frac{(x-1)(x-2)(x-3)}{(x-1)(x-2)}$$ which yields in $$f(x) = x-3$$
This function is now defined for $f(1) = 1-3 = -2$ and $f(x) = 2-3 = -1$ how can this be?
You cancel terms, which is fine as long as the cancelled terms are nonzero. That is, we have $$ \frac{(x-1)(x-2)(x-3)}{x^2-3x+2}=x-3$$ provided $x\ne 1$ and $x\ne 2$. And inded for $x=1$ or $x=2$ the two sides differ: The left side is not even defined.