If$|f(x)-f(y)|\le (x-y)^2$, prove that $f$ is constant
Your deduction that $$\frac{|f(x)-f(y)|}{|x-y|}\le x-y$$ is incorrect because it would lead to $$|f(x)-f(y)|\le |x-y|\cdot(x-y)\ne (x-y)^2$$ To make it work, you may want to deduce that $$\frac{|f(x)-f(y)|}{|x-y|}\le |x-y|$$
Your solution is otherwise correct.