Let $f(x) = x , \ \ 0\le x \lt 2$ and $f(x+2) = f(x)$. Find complex Fourier series of $f(x)$.
If we compute $c_n = \frac{1}{L}\int_{0}^{L}e^{-inx2\pi/L}f(x)dx = \int_{0}^{2}0.5e^{-inx\pi}xdx = \frac{2i\pi n}{\pi^2n^2}$ but if we integrate in other interval with length $2$, we got different answer. For example $\int_{-1}^{1}0.5e^{-inx\pi}xdx = \frac{2i\pi n(-1)^n}{\pi^2n^2}$ which differs from $c_n$ by a factor $(-1)^n$. Why this happens? Integrating over any interval with the length of period should be same.

It is true that $\int_a^{a+2} f(x) dx$ is same for all $a$ but you cannot always substitute $x$ for $f(x)$ in this integral. For example when $x$ is between $-1$ and $0$ we have $f(x) =x+2$.
In your computation of $c_n$ you wrote $f(x)=x$ for $x$ between $-1 $ and $1$. That is not correct.
The function $f$ is defined by $f(x)=x-2n$ if $2n \leq n <2n+1$, $n$ varying over all integers.