As said by @Did, you need to find coefficients a,b,c,d such that
$$M(f)^n=\begin{pmatrix}a&b\\c&d\end{pmatrix}^n=k\begin{pmatrix}1&0\\0&1\end{pmatrix}$$
Thinking to rotation matrices, there is an evident solution :
$$M=\begin{pmatrix}\cos(\frac{\pi}{n})&-\sin(\frac{\pi}{n})\\ \sin(\frac{\pi}{n})&\cos(\frac{\pi}{n})\end{pmatrix}$$
Otherwise said, a possible Möbius (or homographic) transformation is :
$$f_n(x)=\dfrac{\cos(\frac{\pi}{n})x-\sin(\frac{\pi}{n})}{\sin(\frac{\pi}{n})x+\cos(\frac{\pi}{n})}$$
Edit : This rotation is not unique in general. Let us take an example: if $n=12$, you can take any constant $K=1,2,\cdots 11$ in the following matrix
$$M=\begin{pmatrix}\cos(\frac{K\pi}{n})&-\sin(\frac{K\pi}{n})\\ \sin(\frac{K\pi}{n})&\cos(\frac{K\pi}{n})\end{pmatrix}$$
and have $M^n=\pm I_2.$
(following a very judicious remark of "studiosus") a very general type of non trivial matrices $M$ such that $M^n=\pm I_2$, at least among diagonalizable matrices is obtained by thinking to the conjugation operation, that doesn't change the eigenvalues that will still be $e^{iK\pi/n}$ and $e^{-iK\pi/n}$:
$$M=P\begin{pmatrix}\cos(\frac{K\pi}{n})&-\sin(\frac{K\pi}{n})\\ \sin(\frac{K\pi}{n})&\cos(\frac{K\pi}{n})\end{pmatrix}P^{-1}$$
for any invertible matrix $P.$