The statement of the problem:
If $R$ is a ring and $a \in R$, $a$ is idempotent if $a^2 = a$. If the set of all idempotent elements of $R$ is closed under addition, prove that for any $x, y \in R$ we have $x+x = 0, \space xy = yx$. Hint: start with $(x+x)^2$ and $(x+y)^2$.
What's confusing me here is that the statement seems wrong, as I have no idea how to use the fact that the idempotent elements are closed under addition to prove $x+x = 0$ or $xy = yx$ for any $x, y \in R$, but I can't seem to think of a counterexample. The only example where the set of idempotent elements is closed under addition that I could think of is $\mathbb{Z}_{2}$, and the statement indeed holds for that ring. Is there a way to connect an arbitrary element of a ring with the idempotent ones, or is the statement of the problem wrong?
P.S. The statement is easy to prove if we add the requirement that $x, y$ are themselves idempotent: $(x+x)^2 = 4x^2 = 4x$, and since $x + x$ is also idempotent, $(x+x)^2 = x+x =2x$, so $4x = 2x$, so $x+x+x+x=x+x$, so $x+x=0$.
On the other hand, $(x+y)^2 = x + y = x^2+y^2+xy+yx=x+y+xy+yx$, so $xy+yx=0$, and I get stuck here again because $xy = -yx$, which isn't the same as $xy = yx$.
The observation of the characteristic being $2$ is already well covered by Hagen von Eitzen's solution. This is to address the claim that the ring is also commutative.
I think you're right to feel that way.
Consider the free $F_2$ algebra (where $F_2$ is the field of two elements) $F_2\langle x,y\rangle$. Keep in mind that $x$ and $y$ are two indeterminates that do not commute.
We'll say that the "degree" of a polynomial in this algebra is the largest total of exponents of a monomial with nonzero coefficient. So, for example, the degree of $xyxy+x^2y^2x$ is $5$. Clearly if $a,b$ are in the algebra and $deg(b)>0$, then $deg(ab)>deg(a)$. Using this observation, we can see that the idempotents have to have degree $0$, and so the only ones are $\{0,1\}$. (Alternatively, this ring is a domain, so the only idempotents are $\{0,1\}$.)
However, this algebra is not commutative.