Here is an elementary way to show that $ f=1_\mathbb R$
Claim 1: $f$ is an odd function.
If we substitute $x=y=0$ in the given equation, then we get $$f(f(0))=(f(0))^{2}.$$
We then substitute $x=0$ in the given equation and find out that $\forall y \in \Bbb R$, $$f(f(y))=y+(f(0))^{2}.$$ Now, we observe that, for all $x,y \in \Bbb R$, $$y+(f(x))^{2}=f(x^{2}+f(y))=f((-x)^{2}+f(y))=y+(f(-x))^{2}.$$
Hence $\forall x \in \Bbb R,$ $$f(-x)=f(x) \space \space or \space \space f(-x)=-f(x).$$
But, if for some $x \in \Bbb R$, $f(-x)=f(x)$, then we would have, $$x+(f(y))^{2}=f(y^{2}+f(x))=f(y^{2}+f(-x))=-x+(f(y))^{2}$$ for any $y \in \Bbb R$ implying $x=0$. So, for any $x \neq 0$, $f(-x)=-f(x).$
.Hence $f$ is an odd function.
Claim 2: $f(x)>0$ if $x>0$ and $f$ is increasing.
Note that $f(x)\neq 0$ if $x\neq 0$. Indeed, if $f(x)=0$, then
$$0=f(0)=f(f(x))=x.$$ Furthermore, if $x>0$, then $f(x)>0$. Indeed, $f(x)=f(\sqrt{x}^2)=f(\sqrt{x})^2>0$.
Then in fact, $f$ is increasing. Since $f$ is odd, it suffices to show it is increasing on $(0,\infty)$. Well, if $x>y>0$, $$f(x)-f(y)=f(\sqrt{x}^2)+f(-y)=f(\sqrt x)^2+f(-y)=f(x+f(f(-y)))=f(x-y)>0.$$
But then, if $f(x) >x$, $x>f(f(x))>x$. Likewise, if $f(x)<x$, $x=f(f(x))<f(x)<x$.
As these are impossible, we must have $f(x)=x$ for all $x$