What are the actual rules for what can be done to both sides of an equation without gaining/losing solutions.

I understand that if we have an equation like x^2 = x, and we divide by x, we get x = 1, losing the solution x = 0. In general dividing by x can be problematic because the division is not defined at 0.

But are there more general rules for what is and isn't allowed though? The Wikipedia page mentions something about operations being invertible, but doesn't go into much detail.