Let x and y be equal integers, x or y isn't equal to 0 or 1. We have the following:
$x=y$ -subtract x to both sides
$x-x=y-x$
$0=y-x$ -divide y²-x to both sides
$\frac{0}{y^2-x}=\frac{y-x}{y^2-x}$
$0=y$ -divide y to both sides
$0=1$
What's happening?
Your first error is that $\frac{y-x}{y^2-x} \ne y$, but similar (fake) proof could avoid this. The most important thing to note is that you divide $y^2-x$ or $y$ on both side. There is the problem.
When you have an equality $a=b$, you must $\textbf{always}$ check that $b\ne 0$ if you want to conclude that $\frac{a}{b}=1$. Indeed, $\textit{dividing b on both side}$ actually means $\textit{multiply by} \ \frac{1}{b}$ on both side, which is only possible if $b\ne0$.
Now, as said @dxiv, try to do your reasoning with $x=2, y=2$ to see where you cheated.