TITLE: Can the square of a proper ideal be equal to the ideal?
QUESTION [9 upvotes]: Let $R$ be a ring, commutative with $1$, let $\mathfrak{i}$ be an ideal, not the whole ring. In general $\mathfrak{i}^2\subseteq\mathfrak{i}$. Can this inclusion be an equality, or it is always a strict inclusion?

REPLY [10 votes]: 1) A rich source of examples for ideals $I\subset R$ satisfying $I^2=I$ is to take for $R$ an arbitrary product $$R=\prod_{t\in T} R_t$$ of arbitrary rings $R_t$, to choose an arbitrary subset $S\subset T$ and to take for $I$ the ideal $$I=\prod_{t\in T} I_i$$ where $I_t=0$ if $t\in S$ and $I_i=R_i$ if $t\in T\setminus S$. 
2) For finitely generated ideals $I\subset R$ (an empty restriction for noetherian rings) we have a complete classification  of  these ideals :   
Theorem
If a finitely generated  ideal $I\subset R$ satisfies $I=I^2$, then $I$ is principal, generated by an idempotent  : $$I=Re,\quad  e=e^2\in R$$
Proof
Since $I=I\cdot I$, Nakayama tells us that there exists $e\in I$ such that for all $i\in I$ we have $i=ei$.
This immmediately implies (by putting $i=e$) and that $e^2=e$ and $I=Re$.