You can show that the only functions $ f : \mathbb R \to \mathbb R $ satisfying
$$ f \left( x ^ 2 + 2 y f ( x ) \right) + f \left( y ^ 2 \right) = f ( x + y ) ^ 2 \tag 0 \label 0 $$
for all $ x , y \in \mathbb R $, are the identity function $ f ( x ) = x $, and the constant functions $ f ( x ) = 0 $ and $ f ( x ) = 2 $. It's straightforward to verify that these are indeed solution. We try to prove the converse.
Setting $ y = 0 $ in \eqref{0} gives
$$ f \left( x ^ 2 \right) + f ( 0 ) = f ( x ) ^ 2 \text , \tag 1 \label 1 $$
while plugging $ x = 0 $ in it shows
$$ f \big( 2 y f ( 0 ) \big) + f \left( y ^ 2 \right) = f ( y ) ^ 2 \text . \tag 2 \label 2 $$
We can see that $ f ( 0 ) \in \{ 0 , 2 \} $ by putting $ x = 0 $ in \eqref{1}. If $ f ( 0 ) = 2 $, comparing \eqref{1} and \eqref{2}, we get that $ f $ is the constant function with the value $ 2 $, which is one of the mentioned solutions. So, from now on, we consider the case $ f ( 0 ) = 0 $, which in turn makes both \eqref{1} and \eqref{2} equivalent to
$$ f \left( x ^ 2 \right) = f ( x ) ^ 2 \tag 3 \label 3 $$
for all $ x \in \mathbb R $. Assume that there is some $ a \in \mathbb R \setminus \{ 0 \} $ with $ f ( a ) = 0 $. Without loss of generality, we can assume that $ a > 0 $; since by \eqref{3} we have $ f ( - a ) ^ 2 = f \left( ( - a ) ^ 2 \right) = f \left( a ^ 2 \right) = f ( a ) ^ 2 = 0 $, and we could take $ - a $ instead of $ a $. Letting $ x = a $ in \eqref{0} and using \eqref{3} we have $ f ( y + a ) ^ 2 = f ( y ) ^ 2 $ for all $ y \in \mathbb R $. Using this and induction, we get $ | f ( x + n a ) | = | f ( x ) | $ for all $ x \in \mathbb R $ and all $ n \in \mathbb Z $, and in particular $ f ( n a ) = 0 $ for all $ n \in \mathbb Z $. Given this, we can substitute $ x + n a $ for $ x $ and $ - x $ for $ y $ in \eqref{0} and use \eqref{3} to get $ f \left( ( x + n a ) ^ 2 - 2 x f ( x + n a ) \right) + f ( x ) ^ 2 = 0 $. Note that \eqref{3} shows that $ f $ takes nonnegative values at nonnegative points. Thus, for any $ x \in \mathbb R $, if we choose $ n $ large enough, namely $ n \ge \frac { \left| \sqrt { 2 | x f ( x ) | } - x \right| } a $, then both the terms on the left-hand side of the last equation will be nonnegative, and thus both of them must be equal to $ 0 $. This shows that in this case, $ f $ must be the constant function with the value $ 0 $, which is another one of the mentioned solutions. Lastly, consider the other case in which $ 0 $ is the only point at which $ f $ takes the value $ 0 $. Letting $ y = - \frac x 2 $ in \eqref{0} we have $ f \left( x ^ 2 - x f ( x ) \right) = 0 $, and hence $ x ^ 2 - x f ( x ) = 0 $, which gives $ f ( x ) = x $ for all $ x \in \mathbb R \setminus \{ 0 \} $. As we also had $ f ( 0 ) = 0 $, $ f $ must be the identity function, which is the remaining mentioned solution, and we're done.