are $f(f(x))=f(x)$ and $f(x)=x$ equivalent? when I apply $f^{-1}$ to both sides $f(f(x))=f(x)$ $(1)$ we get $f(x)=x$ $(2)$.
are $1$ and $2$ equivalent?
 A: If $f:A\to A$ satisfies $f\circ f=f$, then $f\circ f=f\circ id_A=id_A\circ f$. Thus if $f$ is either left or right cancelable, then $f=id_A$. Since it generally holds that such a function $f$ is left cancelable iff it is injective, while it is right cancelable iff it is surjective, it follows that if $f$ is either injective or surjective, then $f\circ f =f $ implies $f=id$. If $f$ is neither injective or surjective, as in $f:\mathbb R \to \mathbb R$ given by $f(x)=5.8$, then clearly $f\circ f=f$ while $f\ne id_\mathbb R$, so the implication is generally false. 
Finally, it is possible that $f\circ f =f$ without $f$ being either injective or surjective. For instance, let $f:\{1,2,3\}\to \{1,2,3\}$ be given by $f(1)=f(2)=1$ and $f(3)=3$. 
A: Let $f\colon \{0,1\}\to\{0,1\}$ be given by $f(0)=1, f(1)=1$ and note that $f(f(0))=1=f(1)$ but $f(0)=1\neq 0$ hence it is not true for this function $f$. 
A: As others have stated in the comments, this holds if $f$ is injective. Let me give you an example of an non-injective map where it is false. Consider $f:\mathbb R\to\mathbb R$ with $f(x)=0$ for all $x\in\mathbb R$. We have
$$f(f(x)) = f(0) = 0 = f(x)$$
for all $x\in\mathbb R$, but $f(x)=x$ only for $x=0$, not all $x\in\mathbb R$.
As @Louis pointed out, surjectivity of $f$ suffices as well: Let $f(f(x))=f(x)$ for all $x$, then pick any $y$, since $f$ is surjective, $y=f(x)$ for some $x$, so
$$f(y) = f(f(x)) = f(x) = y$
for all $y$.
To conclude: If $f$ is surjective or injective and $f(f(x))=f(x)$ for all $x$, then $f$ is the identity map.
A: Let us assume we have a matrix $F$ that represents application of f.
In matrices this means $$F^2 = F$$
This is the equation that defines a projection.
Projections are diagonalizable and have eigenvalues $0$ or $1$.
We can take an example, a function $$x\to f(x) = |x|$$ on the space of integers $$x\in\{-3,-2,\cdots,2,3\}$$
Our matrix becomes $$F =  \left[\begin{array}{lllllll}&&&&&&\\&&&&&&\\&&&&&&\\&&&1&&&\\&&1&&1&&\\&1&&&&1&\\1&&&&&&1\end{array}\right]$$
It is now a simple exercise in linear algebra to find $F = SDS^{-1}$
We can verify $D_{ii} \in \{0,1\}$
For more general treatment of smooth power-series expandable functions, you might want to consider Carleman matrices.
