How does partial fraction decomposition avoid division by zero?
$\begin{align}{\bf Hint}\quad &\dfrac{3x\!+\!2}{x(x\!+\!1)} = \dfrac{a(x\!+\!1)+bx}{x(x\!+\!1)}\\[.2em] \Rightarrow\ \ \ &3x\!+\!2\, =\, a(x\!+\!1)+bx\ \ {\rm for\ all\ } x\neq 0,-1\\[.2em] \Rightarrow\ \ \ &3x\!+\!2\, =\, a(x\!+\!1)+bx\ \ {\rm for\ all\ }\ x \ \ \ [\,\color{#c00}{0,-1 \ \rm included\,]} \end{align}$
since their difference is a polynomial with infinitely many roots (all $\,x\neq 0,-1)$ so it must be the zero polynomial (recall that 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\,$ is the zero polynomial $\, 0 = p = f -g,\,$ 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.
Good question! This is my crude interpretation (see Bill's answer for a shot of rigor)
What is actually being equated is the numerator, not the denominator. So in your example, you have that
$$\frac{{3x + 2}}{{x\left( {x + 1} \right)}} = \frac{A}{x} + \frac{B}{{x + 1}}$$
if
$$\frac{{3x + 2}}{{x\left( {x + 1} \right)}} = \frac{{A\left( {x + 1} \right) + Bx}}{{x\left( {x + 1} \right)}}$$
if $${3x + 2 = A\left( {x + 1} \right) + Bx}$$
$$3x + 2 = \left( {A + B} \right)x + A$$
which implies
$${A + B}=3$$
$$A=2$$
which in turn gives what you have.
When we equate numerators we "forget" about the denominators. We're focused in the polynomial equality
$$3x + 2 = \left( {A + B} \right)x + A$$
only. Thought it might be unsettling to be replacing by the roots of the denominators, we're not operating on that, so we're safe.
Paying careful attention to the logic of the first step, we are saying that (for a given $A$ and $B$), the equation
$$ \frac{3x+2}{x(x+1)}=\frac{A}{x}+\frac{B}{x+1} $$
holds for all $x \neq 0,-1$ if and only if the equation
$$ 3x+2=A(x+1)+Bx $$
holds for all $x \neq 0,-1$.
Now, if we can find an $A$ and a $B$ so that $3y+2=A(y+1)+By$ holds for all values of $y$, then clearly $3x+2=A(x+1)+Bx $ holds for all $x \neq 0,-1$. So if substituting $y=0$ and $y=-1$ allows us to find $A$ and $B$, then we get a good answer.
Incidentally, a stronger statement is true: the equation
$$ 3x+2=A(x+1)+Bx $$
holds for all $x \neq 0,-1$ if and only if the equation
$$ 3y+2=A(y+1)+By $$
holds for all $y$. So this guarantees that we don't lose any solutions to the former problem when we solve it by instead considering the latter problem.
Aside: if one pays attention to what they mean, one doesn't really need to to introduce a new dummy variable $y$. However, I hoped it might add a bit more clarity if the variable $x$ is always restricted to be $\neq 0,-1$.
It may be useful to note that you use a similar sort of reasoning for limits. e.g. to find the value of
$$ \lim_{x \to 0} \frac{x^2}{x} $$
you observe that $x^2/x = x$ for all $x \neq 0$ so that
$$ \lim_{x \to 0} \frac{x^2}{x} = \lim_{x \to 0} x$$
and then you apply the fact that $x$ is continuous at $0$ to obtain
$$\lim_{x \to 0} x = 0$$