You used the fact that you can multiply both sides of an equality by the same, non-zero constant.
So, if you start with the trivial equality
[tex]x=x[/tex]
you can multiply both sides by 3:
[tex]3x=3x[/tex]
But if [tex]x=3[/tex], [tex]3x[/tex] becomes [tex]3\cdot 3[/tex], which is [tex]3^2[/tex]. So, we have
[tex]3^2=3\cdot 3[/tex]
which leads to
[tex]x^2=3x[/tex]
if you recall that [tex]x=3[/tex]