Why do I only get one answer when evaluating $x^2=2x$? What this question is not about

*

*I know to expect two answers $\{2,0\}$, (I can test them, by plugging them into the equation).

*I know how to get them graphically.

*I know how to get the algebraically:

*

*$x^2 = 2x$

*$x^2 - 2x = 0$

*$(x-2)(x-0)=0$

*$(x-2)(x)=0$

*$x=0, x=2$
However
My first attempt got only one answer, and I see nothing else wrong with it.

*

*$x^2 = 2x$

*$x = 2$ (by dividing by $x$)

What am I doing wrong? How can I detect this error early? I can catch this error at the end, as I expect two answers. In this case there is little difference between the point of error and the end, but in more complex problems there may be a long time between them, so I would like to catch this earlier. How do I know where I went wrong?

$$x^2=2x$$
If $x \neq 0$, we can divide by $x$:
$$x=2$$
And you should check what happens if $x=0$. Similarly: 
$$(x-2)(x-3)x=2x(x-2)$$
If $x-2 \neq 0$ we can divide by $x-2$:
$$x(x-3)=2x$$
If $x \neq 0$ we can divide by $x$:
$$x-3=2$$
$$x=5$$
And we should go back and check what happens if $x=0$ or $x-2=0$.
