Can you cancel out a term if equal to zero?
As a teacher, I would prefer to enjoin my students to eradicate the word “cancel” from their vocabulary and the supposed process of cancellation from their technique. What we may do is multiply both sides of an equation by any number, knowing that the equality will be preserved. In the example, you are trying to multiply by $1/0$, not a number.
Cancelling out $(x-y)$ is done by dividing through the equation by $(x-y)$ (on both sides), and since we cannot divide by $0$ (I'm assuming you know this), we cannot cancel $(x-y)$ when it is $0$.
I should add a small example. Consider the following equation, and we want to find the real solutions $x$: $$x^2=3x $$ Now it would be smart to cancel $x$ from each side, but by dividing through with $x$ assumes that $x\neq 0$, so we have to check that possibility separately. Assuming that $x\neq0$ the equation simplifies to \begin{align} \frac{x^2}{x} &=\frac{3x}{x}\\ x &= 3 \end{align} So one solution is $x=3$, but until now we have assumed that $x\neq 0$, so let us check the possibility that $x=0$: \begin{align} 0^2 &= 3\cdot 0\\ 0 &= 0 \end{align} which is true, so the solutions to this equation are $x=3$ and $x=0$.
It sounds as if the 'proof' you were asked to work on was a variation of the following:
$$ \begin{align} a^2 - a^2 & = a^2 - a^2 \tag{1} \\ a \cdot (a-a) & = (a+a) \cdot (a-a) \tag{2} \\ a & = a+a \tag{3} \\ a & = 2a \tag{4} \\ 1 & \overset{?}{=} 2 \tag{5} \\ \end{align} $$
My grandfather, a maths teacher, told this as a joke. I remember confusing at least one of my maths teachers with it (yeah, I know).
The problem is that calling it 'cancelling' hides what's really going on. You're not cancelling anything, you're multiplying or dividing.
To arrive at $(3)$ from $(2)$, you're supposed to 'cancel' $(a-a)$. But it's not cancelling, it's dividing! And dividing by $(a-a)$ is dividing by $0$, which as we all know is not good. Had $(2)$ read $a\cdot0 = (a+a)\cdot0$, you wouldn't have dreamed of 'cancelling' the $0$.
Incidentally, the step from $(4)$ to $(5)$ isn't correct either, since you're disregarding the possibility that $a$ — which you're dividing by — could be $0$. But by then you're already so far down the rabbit hole you probably won't notice.
As an aside, another fun invalid "cancellation" $$\require{cancel} \frac{16}{64} = \frac{1\cancel{6}}{\cancel{6}4} = \frac{1}{4} $$