They are not working on the same variable. In $∀x(L(x)->∃x M(x,y))$, the outer variable $x$ is bounded to the all-quantifier. In $\exists x[M(x,y)]$, $x$ is bounded by the existential quantifier. You could rename it such as in $∀x(L(x)->∃z M(z,y))$. On the other hand, $y$ is a free variable.