Why is this method right to solve some equations of degree 2? Given this equation
$-x^2+x+6=4$
We can write it as
$(3-x)(x+2) = 4$
So weridly if I take
$(3-x) = 4$ and $(x+2) = 4$, I can get $x=-1$ and $x=2$ that are indeed the correct solutions.
Why does this happen? And in which cases can this occur?

Note that the given equation can be rewritten as
$$(x+1)(x-2)=-[(3-x)-4][(x+2)-4]=0$$
which leads to $3-x=4$ and $x+2=4$.
