Hint $\ $ If $\,n\,$ is composite and not a prime power then $\,\Bbb Z/n\,$ has an idempotent $\not\equiv 1,0\,$ since then $\,n = ab,\,$ coprime $\,a,b>1$ so by CRT $\ \exists\,x\equiv (1,0)\ {\rm mod}\ (a,b)\,$ so $\,x^2\equiv (1,0)^2\equiv (1^2,0^2)\equiv x.\,$
Further if $\,n\,$ is not squarefree then a prime power $\,p^2\mid n\,$ so $\,{\rm mod}\ n\!:\ n/p\not\equiv 0,\,$ but $\, (n/p)^2\equiv 0$
Finally, $ $ if $\,n> 2\,$ then $\ {-1}\not\equiv 1,0,\ $ so $\ {-}1\,$ is a nontrivial unit.
Example $\ $ Simple cases arise for $\, n = p^2q,\,$ primes $\,p\ne q, \,$ e.g. $\ 2^2\cdot 3 = 12.\,$ Then, as above we have an idempotent $\,x\equiv (1,0)\ {\rm mod}\ (3,4)\!\!\overset{\rm CRT}\iff\! x\equiv 4\pmod{12},\,$ indeed $\,4^2\equiv 4\pmod{12}.$
Further we have the nonzero nilpotent $\,n/p = pq\,$ with $\,n^2\! = p^2q^2 \equiv 0\pmod {p^2q}.\,$ In our example $\, n/p = 12/2 = 6,\,$ and $\,6^2\equiv 0\pmod{12}.$
Remark $\,\ \color{#c00}{\rm Nontrivial\,}$ idempotents, i.e. elements satisfying $\,x^2 = x\,$ (and $\,\color{#c00}{x\neq 0,1})$ are intimately connected to coprime factorizations (of both elements and rings). As was explained above, by CRT, modulo any non-prime-power composite $\,n,\,$ there are nontrivial idempotents $\,(0,1),(1,0).$
Some integer factorization algorithms work by searching for nontrivial idempotents mod $\,n,\,$ which immediately yield a factorization of $\,n\,$ (generally one can quickly factor $\,n\,$ given any polynomial which has more roots mod $\,n\,$ than its degree, so any notrivial idempotent or nontrivial square-root will split $\,n,\,$ since it yields a quadratic with $\,\color{#c00}3\,$ roots).