I know this question was probably written without any thought of leaving $\mathbb R$ or $\mathbb C$, but I think it's a good opportunity to sharpen the question and show the big picture. The question apparently is, or could be:
How can I algebraically prove that if $x^n=x$ for all positive integers $n$, then $x=1$ or $x=0$?
(IMO the idea of discarding $0$ as a solution -- on the grounds of a particular chosen value of $0^0$ or otherwise -- is far less natural than just restricting the powers to be positive integers.)
There's actually no problem with immediately generalizing this to:
If $R$ is a ring with identity $1$ and no nonzero zero divisors, $x^2=x$ implies $x=1$ or $x=0$.
The proof has pretty much already been given above: if $x^2-x=0$, then $x(x-1)=0$, and by assumption either $x=0$ or $(x-1)=0$. This is just assuming the proposed problem for $n=2$, so of course requiring it for $n>2$ does no add anything new. (And assuming "$n$ is any number is a bit overkill too.)
But that is not quite the end of the story. You see, it was important here that the ring did not have nonzero zero divisors. In fact, there are very natural rings that don't have that property, and the proposed problem fails piteously. Namely:
There exists an infinite Boolean ring $R$, that is, a ring in which $x^2=x$ for all $x\in R$. In such a ring, $x^n=x$ for every element of the ring, for every positive integer $n$.
I chose that one to maximize the number of things being badly behaved, but of course it has nothing to do with cardinality. A Boolean ring with $4$ elements serves equally well to show that we could potentially have more than just $0$ and $1$ doing this.