Let $(M, \mathcal{B} , \mu)$ be a measure space and $f : M \to M$ be a measurable transformation. We say that the measure $\mu$ is invariant under $f$ if for every measurable set $ E \subset M$, $$\mu (E) = \mu (f^{-1}E).$$ There is a well-known theorem in ergodic theory which determine the invariant measures of $f$:
Theorem: Let $ f : M \to M $ be a measurable transformation and $\mu$ be a measure on $M$. Then $f$ preserves $\mu$ if and only if $$ \int \phi d\mu = \int \phi \circ f d\mu$$ for every $\mu$-integrable function $\phi : M \to \mathbb R$.
For the proof, see Proposition $1.1.1$ from Foundations of Ergodic Theory, by Marcelo Viana and Krerley Oliveira. In the previous book, the authors have asked the following exercise:
Prove that if $f : M \to M$ preserves a measure $\mu$ then, given any $k ≥ 2$, the iterate $f^k$ also preserves $\mu$. Is the converse true?
The fact that $f^k$ for $k\ge 2$ preserves $\mu$ can be obtained by a simple induction from above theorem. For the converse, since $\mu$ is $f^2 $ and $f^3$-invariant, by the above theorem, for every $\mu$-integrable function $\phi : M \to \mathbb R$, $$ \int \phi d\mu = \int \phi \circ f^2 d\mu = \int \phi \circ f^3 d\mu.$$ Specially, for the function $ \phi \circ f : M \to \mathbb R$ we must have: $$ \int \phi \circ f d\mu = \int (\phi \circ f)\circ f^2 d\mu = \int \phi \circ f^3 d\mu = \int \phi d\mu .$$ Again by above theorem, $\mu$ is $f$-invariant.
I have doubt about my solution, since I used only the assumption that $f^2$ and $f^3$ preserves $\mu$. Did i missed something?
Your proof is not wrong.
However, the fact that each $f^k$ preserves $\mu$ follows immediately by the definition, you don't really need the theorem you cite.
Similarly, for the converse, you can just say that $\mu(f^{-1}E)=\mu(f^{-2}f^{-1}E)=\mu(f^{-3}E)=\mu(E)$.