If $k\in\Bbb R$ is fixed, find all $f:\Bbb R\to\Bbb R$ that satisfy $f(f(x))=k$ for all real $x$.
If $k\ge 0$, $f(x)=|k+g(x)-g(|x|)|$ is a solution for any $g:\Bbb R\to\Bbb R$.
If $k\in\Bbb R$ is fixed, find all $f:\Bbb R\to\Bbb R$ that satisfy $f(f(x))=k$ for all real $x$.
If $k\ge 0$, $f(x)=|k+g(x)-g(|x|)|$ is a solution for any $g:\Bbb R\to\Bbb R$.
Choose arbitrary subsets $A,B\subseteq\mathbb R$ such that $A\cup B=\mathbb R$ and $A\cap B=\emptyset$. We may assume without loss of generality that $k\in B$. Let $g:A\to B$ be an arbitrary function. Then define $$f(x)=\begin{cases}k;&x\in B,\\ g(x);&x\in A.\end{cases}\tag{$\ast$}$$ This clearly satisfies the requirements.
Conversely, if $f:\mathbb R\to\mathbb R$ is any function that satisfies $f(f(x))=k$, we may choose $B=f(\mathbb R)$ and $A=\mathbb R\setminus B$ which shows that $f$ is of the form given above.
So $(*)$ in fact gives all possible solutions.