We know that when a ring is an integral domain, we have that:
$$x^2=x \implies x^2-x = 0 \implies x(x-1) = 0$$
Since this is an integral domain, a product giving $0$ forces one of the the terms in the product to be $0$, therefore the solutions are:
$$x=0, x -1 = 0$$
However, what about when we have a ring but that's not an integral domain, can we find solutions to this equations such that neither of the two terms are $0$?
Yep. In $\mathbb{Z}_6$ let $x=3$. Then $x^2 - x = 9-3 = 6 = 0$. Of course $3\neq 0\wedge (3-1)\neq 0$.
It is possible in $\mathbb{Z}_n$, if $n = k(k-1)$ for some $k\in\mathbb{N}$.