We consider the equation $$f(f(x))-2f(x)+x=0,$$ where $f:\mathbb{R} \to \mathbb{R}$ is a continuous function. The question is to prove that $f(x)=x+c$.
I proved that $f$ is strictly increasing and that $f(\mathbb{R})=\mathbb{R}$. So $f$ and $f^{-1}$ verify the following equivalent equations $$ f(x)+f^{-1}(x)=2x, \qquad f^{-1}(f^{-1}(x))-2f^{-1}(x)+x=0. $$ and that if we put $c=f(0)$ then $f(nc)=(n+1)c$, for all $n\in \mathbb{Z}$.
There is any way to extend this for all real numbers ?
Let $f$ be a solution function. Let's show that $f$ is necessarily injective. Indeed, suppose $x$ and $y$ are real numbers such that $f(x) = f(y)$. It is clear that $(f\circ f)(x) = (f\circ f)(y)$, and using the equation
$$ x=2\,f(x)-(f\circ f)(x)=2\,f(y)-(f\circ f)(y)=y. $$
Since $f$ is continuous on $\mathbb{R}$ and injective, it is strictly monotonic on $\mathbb{R}$. Since both $f\circ f$ and $\mathrm{id}_{\mathbb{R}}$ are strictly increasing in $\mathbb{R}$, the equation $f\circ f + \mathrm{id}_{\mathbb{R}} = 2\,f$ implies that $f$ is also strictly increasing.
The bijection theorem then ensures that $f\colon \mathbb{R}\to f(\mathbb{R})$ is bijective. To determine $f(\mathbb{R})$, we will calculate the limits of $f$ at the endpoints. The monotone limit theorem ensures that $f$ has a limit at $+\infty$ in $\mathbb{R}\cup\{+\infty\}$.
Suppose the limit is $\ell\in\mathbb{R}$ and let's argue by contradiction. Since $$ \forall x\in\mathbb{R},\qquad f(f(x))-2\,f(x)=-x $$ by taking the limit as $x$ approaches $+\infty$, we arrive at a contradiction because the left-hand side has a finite limit while the right-hand side tends to $-\infty$.
We deduce that the limit of $f$ at $+\infty$ is $+\infty$. Similarly, we reason to show that $f$ tends to $-\infty$ as $x$ approaches $-\infty$. Thus, the function $f$ is a strictly increasing continuous bijection from $\mathbb{R}$ to $\mathbb{R}$.
Let's now show that the function $\phi\colon x\mapsto f(x)-x$ is constant on $\mathbb{R}$. The equation satisfied by $f$ can be written as $\phi\circ f=\phi$. An easy recurrence argument shows that $\phi\circ f^n=\phi$ for all $n\in\mathbb{N}$. Since $f$ is bijective, we also have $\phi\circ f^{-1}=\phi$, then $\phi\circ f^n=\phi$ for all $n\in\mathbb{Z}$.
With the definition of $\phi$, this relation can be written as $f^{n+1}(x)-f^{n}(x)=\phi(x)$ for all $x\in\mathbb{R}$ and for all $n\in\mathbb{N}$. Now, we have $$ \sum_{k=0}^{n-1} \bigl(f^{k+1}(x)-f^{k}(x)\bigr)=\sum_{k=0}^{n-1} \phi(x) $$ and then, by calculating the sum, we obtain $f^{n}(x)-x=n\phi(x)$ and $\phi(x)=\frac{f^{n}(x)}{n}-\frac{x}{n}$ for all $x\in\mathbb{R}$ and for all $n\in\mathbb{N}^*$. Therefore, for all $x\in\mathbb{R}$, $$ \lim_{n\to{+\infty}}\frac{f^{n}(x)}{n}=\phi(x). $$ This gives us a new definition of $\phi$.
If we manage to show that the above limit is independent of $x$, then $\phi$ will be constant. Let's fix $a\in\mathbb{R}$ throughout. The sequence $(f^{n}(a))_{n\in\mathbb{Z}}$ is an arithmetic sequence with a common difference $r_{a}=f(a)-a$.
$\triangleright$ If $r_{a}=0$ for all $a\in\mathbb{R}$, then $f=\text{id}_{\mathbb{R}}$; in particular, $\phi$ is constant.
$\triangleright$ If $r_{a}> 0$, then $f^{n}(a)=a+nr_{a}$ for all $n\in\mathbb{Z}$, so $(f^{n}(a))$ tends to $+\infty$ as $n$ approaches $+\infty$ and to $-\infty$ as $n$ approaches $-\infty$. For a given $x\in\mathbb{R}$, there exists $m\in\mathbb{Z}$ such that $$ f^{m}(a)\leq x\leq f^{m+1}(a) $$ and since $f^{n}$ is strictly increasing, $$ f^{m+n}(a)\leq f^{n}(x)\leq f^{m+n+1}(a) $$ then for large enough natural numbers $n$, $$ \frac{m+n}{n}\frac{f^{m+n}(a)}{m+n}\leq \frac{f^{n}(x)}{n}\leq \frac{m+n+1}{n}\frac{f^{m+n+1}(a)}{m+n+1} $$ which, by taking the limit $n\to+\infty$, gives $\phi(a)\leq \phi(x)\leq \phi(a)$, and thus $\phi(a)=\phi(x)$. Since $x$ is an arbitrary real number, we have shown that $\phi(x)=\phi(a)$ for all $x\in\mathbb{R}$, making $\phi$ constant.
$\triangleright$ If $r_{a}<0$, the reasoning is quite similar.
The function $\phi$ is therefore constant, so there exists $c\in\mathbb{R}$ such that $f=\mathrm{id}_{\mathbb{R}}+c$. Conversely, these functions satisfy the conditions of the statement. The set of solutions to the problem is $$ \left\{\mathrm{id}_{\mathbb{R}}+c\ |\ c\in\mathbb{R}\right\}. $$