Are you actually allowed to do that? Because when it comes to normal algebra you would usually minus to find x.
In solving (x-1)² = 2(x-1), you CAN'T divide by (x-1) because x=1 is a zero of BOTH the LHS and RHS, and hence a solution of the equation, so that solution is lost in doing the division.
When solving sinx = cosx, you CAN divide by cosx because there are NO values of x for which sinx and cosx are BOTH zero.
So even though the zeros of cosx will lost by dividing, those zeros won't be solutions of the equation.