Consider the second equation, i.e. a^2 = ab. Subtracting ab from both sides gives you a^2 - ab = 0. If you look at the last equation (with the a's and b's in it) and substitute in 0 for the expression a^2 - ab as just obtained, on both sides, you have 2 x 0 = 1 x 0, i.e. 0 = 0 which is perfectly correct. The error is to cancel on both sides an expression that you've shown to be equal to zero, otherwise you can "prove" an infinite number of absurdities, e.g. if 1 x 0 = 100 x 0, then cancelling the zeros on each side would "prove" that 1 = 100, etc.

Consider the second equation, i.e. a^2 = ab. Subtracting ab from both sides gives you a^2 - ab = 0. If you look at the last equation (with the a's and b's in it) and substitute in 0 for the expression a^2 - ab as just obtained, on both sides, you have 2 x 0 = 1 x 0, i.e. 0 = 0 which is perfectly correct. The error is to cancel on both sides an expression that you've shown to be equal to zero, otherwise you can "prove" an infinite number of absurdities, e.g. if 1 x 0 = 100 x 0, then cancelling the zeros on each side would "prove" that 1 = 100, etc.