You should add some continuity assumption. Otherwise here is a counterexample.
Let $f(x)=\chi_{(0,1]}(x)$, so $f^2(x)=f(x)^2=f(x)$. By induction, this implies that $f^n(x) = f(x)^n = f(x)$ for every $n$.
Without continuity assumption you can create infinite many counterexamples using the so-called simple functions, $f=\sum_{j=1}^mc_j\cdot\chi_{E_j}$ where $(E_j)_j$ are disjointed subsets. So $f^n(x)$ and $f(x)^n$ depend only on $c_1,\dots,c_m$ and $E_1,\dots,E_m$. You can make $c_j$ to be the roots of certain polynomials and $E_j$ to be arbitrary sets which contain or not contain certain $c_k$.
For example, take $E$ such that $-1,1\in E$ and take $f=\chi_E-\chi_{E^c}$, so $f^2(x)=f(x)^2\equiv1$. This is a case for $n=2$. If you take $1\in E$ and $-1\in E$ you get $f^3(x)=f(x)^3$ and then by induction $f^{2k+1}(x)=f(x)^{2k+1}$.