This is a subtle point, so I understand your confusion. In general, if $P(x) = R(x)\cdot Q(x)$, $P,Q,R$ being polynomials, it is easy to see that $\frac{P(x)}{R(x)} = Q(x)$ for all $x$ not being roots of $R(x)$, but the left side has the problem of not a priori being well defined for $x$ a root of $R(x)$. It should actually be regarded as a convention, rather than a result, that when we write $\frac{P(x)}{R(x)}$ we actually mean $Q(x)$.
If you are really mad at this convention, you can think of it like this: we extend the domain of $f(x) = \frac{P(x)}{R(x)}$ to the roots of $R$ by continuity (i.e. $f(r):=\lim_{x\to r}\frac{P(x)}{R(x)}$ for $r$ a root of $R(x)$), which will give us the correct value (i.e. $f(r) = Q(r)$).
This phenomenom is much more general than just polynomials, and happens in fields such as complex analysis and geometry as well.
It is really a clash of notation versus the actual underlying objects. As demonstrated in the comments, doing polynomial division really yields that the resulting function is again a polynomial, and so, all should be well. The division notation and our notion of "plugging in" values of $x$ must be disregarded in this context.