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$