Solution by JerryZYang.
I claim that the solution is f(x)=x, verifying is easy.
Let P(x,y) denote the assertion. Taking P(x,0) gives
f(f(x))=x
meaning f is an involution. Thus f is surjective and injective. P(f(x),y) gives
f(f(f(x))+y2)=f(x)+y2⟺f(x+y2)=f(x)+y2.
Let a<b be two arbitrary reals, P(a,b−a) gives
f(a+b−a)=f(a)+(b−a)⟺f(b)−b=f(a)−a.
Thus f(x)−x is constant for all reals, and so f(x)=x+c. Substituting this back into the original equation gives f(x)=x as desired.