Suppose $R$ is a commutative ring and $RR= R$(ideal multiplication). Then, $R$ has an identity. I am currently reading Hungerford. I am trying to prove theorem 2.19 i.e. every maximal ideal is prime provided that $R$ is unital and commutative. Hungerford states that if you prove $RR = R$, then $R$ is unital which I don't understand. Sorry if this is a stupid question.
 A: This isn't true. What Hungerford is saying that if $R$ is commutative and $RR = R$ then $R$ has the property that maximal ideals are prime. He then remarks that unital rings are the most particular/common example of rings with property that $RR=R$.
In any case, here is a counterexample. Consider $\oplus_{i = 1}^{\infty} \mathbb{Z}_2$ ($\oplus$ means finite support). Note that we have that $x^2 = x$ for all $x$ and so $R^2 = R$ here.
A: I think you've misread what Hungerford says.
Here is Theorem III.2.19:

Theorem. If $R$ is a commutative ring such that $R^2=R$ (in particular if $R$ has an identity), then every maximal ideal $M$ in $R$ is prime. [emphasis added]

Hungerford is not saying that if a commutative ring $R$ satisfies $R^2=R$ then $R$ has an identity. It is saying instead that one particular instance in which the condition $R^2=R$ will be satisfied is when $R$ has an identity.
You may have missed the "if" after "in particular". Had the statement read "in particular $R$ has an identity", then this should be understood as saying that the condition $R^2=R$ implies, among other things, that $R$ has an identity; this seems to be what you interpreted. But the "if" means that instead the statement should be understood to mean that "one case, among others, in which this occurs is when $R$ has an identity."
In fact, as noted, the condition $R^2=R$ is more general than having an identity: there are rings without identity that satisfy the condition but do not have an identity. Another example to the one given is the ring of continuous functions $f\colon \mathbb{R}\to\mathbb{R}$ with compact support. For every $f\in R$ there exists $g\in R$ such that $fg=gf=f$, but there is not element $e$ of $R$ with the property that for all $h\in R$ we have $eh=he=h$.
