A standard example of such a ring is the ring $R$ of functions $f\colon\mathbb{R}\to\mathbb{R}$ of compact support; that is, functions $f\colon\mathbb{R}\to\mathbb{R}$ for which there exists an $M>0$ (which depends on $f$) such that $\mathrm{supp}(f)=\{x\in\mathbb{R}\mid f(x)\neq 0\}\subseteq [-M,M]$, with pointwise addition and multiplication ($(f+g)(x) = f(x)+g(x)$, $(fg)(x) = f(x)g(x)$).
This ring does not have an identity; given any $f\in R$, let $M_f>0$ be such that $\mathrm{supp}(f)\subseteq [-M_f,M_f]$. Then let $g$ be given by $g(M_f+1)=1$, $g(x)=0$ for all other $x$. Then $g\in R$, buth $fg = 0\neq g$. Thus, $f$ cannot be an identity of $R$.
However, in this ring we have $R^2=R$: given any $f\in R$, let $M_f>0$ be such that $\mathrm{supp}(f)\subseteq [-M_f,M_f]$, and let $g\colon\mathbb{R}$ be defined by $g(x)=1$ if $x\in[-M_f,M_f]$, and $g(x)=0$ otherwise. Then $f=fg\in R^2$, so $R\subseteq R^2\subseteq R$.
You can even do this with the set of all continuous functions of compact support; or the set of continuous functions that vanish at infinity. These are standard examples of rings without unity, but which have "local" unities: given any $f\in R$, there exists $g\in R$ such that $gf=fg=1$. Such rings always satisfy $R^2=R$.