It depends on what you mean by ”remove”?
As Dr. Peterson says, you cannot DIVIDE by [imath](x - 1)^2[/imath] if that equals zero.
If you mean REPLACE the expression [imath](x - 1)^2[/imath] by zero in order to consider the special case of
[imath](x - 1)^2 = 0[/imath], you can do that, but be careful.
If you mean EXPAND both the left hand and right hand sides by carrying out the indicated operations, you can do that.
Part of math is being careful in what you mean. “Remove” is not an arithmetic operation.