$\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.