TITLE: If $f(g(x)) = g(x)$, what is $f(x)$?
QUESTION [5 upvotes]: If $f(g(x)) = g(x)$ then can we conclude $f(x)=x$?
  (In fact, $g(x) = x + 2f(x)$.)

Or which properties should $g(x)$ satisfy? (like one-to-one, etc.)

REPLY [5 votes]: This is the question I am answering:

If some functions $f$ and $g$ are such that $f(g(x)) = g(x)$ and $g(x) = x + 2f(x)$ for every $x$, can we conclude that $f(x)=x$ for every $x$? More generally, which properties should such a function $g$ satisfy, such as, being one-to-one, etc.?

If $f\circ g=g$ and $g(x)=x+2f(x)$ for every $x$ then $2f\circ g=g\circ g-g$ hence $g\circ g=3g$. Conversely, if $g\circ g=3g$, define $f$ by $f(x)=\frac12(g(x)-x)$, then $f\circ g=g$ and $g(x)=x+2f(x)$ for every $x$. This shows one is reduced to study the solutions of the functional equation  $g\circ g=3g$. 
To answer succinctly the main question in the post, the obvious solution $g:x\mapsto3x$ is not the only one hence no, one cannot conclude that $f:x\mapsto x$.
For a counterexample, let $X\subset\mathbb R$ and $h:X\to \mathbb R\setminus X$ and consider the function $g$ defined by $g(x)=3x$ for every $x$ not in $X$ and $g(x)=h(x)$ for every $x$ in $X$. Then $g\circ g=3g$ but $g$ need not be the function $x\mapsto3x$, nor a regular function, nor one-to-one, nor onto. 
Note that $X$ can be as large as one wants, as long as $X\ne\mathbb R$, and that $h$ can be any function whose image is included in $\mathbb R\setminus X$. This leaves plenty of room for "pathological" examples.
To be fully specific (while being not too pathological), consider the function $f$ defined by $f(x)=x$ for every $x$ not in $\mathbb Q$ and $f(x)=\frac12(\pi-x)$ for every $x$ in $\mathbb Q$.