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