I'm reading this answer of The logic behind partial fraction decomposition, I think my question is too basic and not directly related to the answer so I don't comment there. I don't understand why:
\begin{align} f(x) - \frac{c_r}{x - r} = \frac{1}{x - r} \left( \frac{P(x)}{R(x)} - \frac{P(r)}{R(r)} \right). \end{align} The expression in parentheses approaches $0$ as $x \to r$, and in fact it is a rational function whose numerator is divisible by $x - r$, so we can actually divide by $x - r$.
Why $\left( \frac{P(x)}{R(x)} - \frac{P(r)}{R(r)} \right)$ is divisible by $x-r$?
What I understand a little about the partial fraction is that it's because something forms a vector space so the $f(x)$ can be expressed/decomposed like that, but I'm not sure.
I'm not clear what the difficulty is. So, let's work through the algebra first.
Recall (first paragraph of the answer you cite), $f(x) = P(x)/Q(x)$ and $Q(x) = (x-r)R(x)$ and also (second paragraph) $c_r = P(r)/R(r)$. So, \begin{align*} f(x) - \frac{c_r}{x-r} &= \frac{P(x)}{Q(x)} - \frac{c_r}{x-r} \\ &= \frac{P(x)}{(x-r)R(x)} - \frac{c_r}{x-r} \\ &= \frac{P(x)}{(x-r)R(x)} - \frac{P(r)}{(x-r)R(r)} \\ &= \frac{1}{x-r} \cdot \frac{P(x)}{R(x)} - \frac{1}{x-r} \cdot \frac{P(r)}{R(r)} \\ &= \frac{1}{x-r} \left( \frac{P(x)}{R(x)} - \frac{P(r)}{R(r)} \right) \text{.} \end{align*}
So, perhaps the hiccup isn't the algebra, but is in why $f$, $Q$, and $c_r$ have the specified values?
Your comments make me think we should cover why the facts I "recall" above are true.
You might be concerned that $Q$ has some other factorization that doesn't include $x-r$. But we know $Q$ is zero at $r$. The only way a product of things can be zero is when one (or more) of them are zero. So, any factorization of $Q$ includes a factor of $x-r$.
As an example, if $(x-s)^3(x-t)$ is a common factor of $P$ and $Q$, then we work with $P'(x)$ and $Q'(x)$ where $P'(x) = \frac{P(x)}{(x-s)^3(x-t)}$ and $Q'(x) = \frac{Q(x)}{(x-s)^3(x-t)}$, so $\frac{P(x)}{Q(x)} = \frac{(x-s)^3(x-t)P'(x)}{(x-s)^3(x-t)Q'(x)} = \frac{P'(x)}{Q'(x)}$ is an identity.
(Note that being an identity means that the expressions all agree wherever they are all defined. $P'$ and $Q'$ are undefined at $s$ and $t$. In fact, $f = \frac{P}{Q}$ is undefined at the zeroes of $Q$ because division by zero is undefined. When we factor the common factors of $P$ and $Q$ out, we get a new, simpler expression, but the zeroes of $Q$ are still not in the domain of $f$, so they are "holes" in the graph of $f$. The coordinates of these holes are found by evaluating the cancelled fraction at the $x$-coordiante of the hole, $\left(s, \frac{P'(s)}{Q'(s)}\right)$ and $\left(t, \frac{P'(t)}{Q'(t)}\right)$. When we graph $P'(x)/Q'(x)$ it goes through these points. The graph of $P(x)/Q(x)$ is the same, except we delete those two points.)