This may be an incredibly stupid question, but why does partial fraction decomposition avoid division by zero? Let me give an example:
$$\frac{3x+2}{x(x+1)}=\frac{A}{x}+\frac{B}{x+1}$$
Multiplying both sides by $x(x+1)$ we have:
$$3x+2=A(x+1)+Bx$$
when $x \neq -1$ and $x \neq 0$.
What is traditionally done here is $x$ is set to $-1$ and $0$ to reveal: $$-3+2=-B \implies 1=B$$ and $$2=A$$
so we find that
$$\frac{3x+2}{x(x+1)}=\frac{2}{x}+\frac{1}{x+1}$$
Why can $x$ be set equal to the roots of the denominator (in this case, $0$ and $-1$) without creating a division by zero problem?
$\begin{align}{\bf Hint}\quad \dfrac{f(x)}{h(x)}=\dfrac{3x\!+\!2}{x(x\!+\!1)} &= \dfrac{a(x\!+\!1)+bx}{x(x\!+\!1)}=\dfrac{g(x)}{h(x)}\\[.3em] \Rightarrow\ \ \ \ \ 3x\!+\!2\,\ &=\ a(x\!+\!1)+bx\ \ {\rm for\ all\ }\, x\neq 0,-1\\[.3em] \Rightarrow\ \ \ \ \ 3x\!+\!2\,\ &=\ a(x\!+\!1)+bx\ \ {\rm for\ all\ }\, x \ \ \ (\,\color{#c00}{0,-1 \ \rm included\:\!)} \end{align}$
since their difference $\, f(x)- g(x)\,$ is a polynomial with infinitely many roots (all $\,x\neq 0,-1)$ so it is the zero polynomial (recall a nonzero polynomial over a field has no more roots than its degree).
Generally $ $ If $\,f,g\,$ and $\,h\!\ne\! 0\,$ are polynomial functions over $\,\mathbb R\,$ (or any $\rm\color{#0a0}{infinite}$ field) then
$$\begin{eqnarray} \smash[b]{\dfrac{f(x)}{h(x)} = \dfrac{g(x)}{h(x)}} \,&\Rightarrow&\ f(x) = g(x)\ \ {\rm for\ all}\,\ x\in\mathbb R\, \ {\rm such\ that}\,\ h(x)\ne 0\\[.2em] &\Rightarrow&\ f(x) = g(x)\ \ {\rm for\ all}\ \,x\in \mathbb R \end{eqnarray}\qquad$$
by $\,p(x) = f(x)\!-\!g(x) = 0\,$ has $\rm\color{#0a0}{infinitely}$ many roots [all $\,x\in \mathbb R\,$ except finite #roots of $\,h(x)$], $ $ hence $\,p=f-g\,$ is the zero polynomial, so $\, f = g.$
Thus to solve for coef's $\,a,b\,$ that occur in $\,g\,$ it is valid to evaluate $\,f(x) = g(x)\,$ at any $\,x\in \mathbb R,\,$ since it holds true for all $\,x\in \mathbb R\,$ (including all real roots of $\, h).$
Remark $ $ The method you describe is known as the Heaviside cover-up method. It can be generalized to higher-degree denominators as I explain here.
See here for some analogous methods applied in other contexts.