I try to visualize this in terms of something analogous to vector spaces in linear algebra because thats the only way I can understand the fourier series.
You have a basis {$\cos(0x), \sin(0x), \cos(x), \sin(x), \cdots, \cos(nx), \sin(nx), \cdots $}
and you can represent any function as a linear combination of these (whats analogous to base vectors in linear algebra) if you can find sensible coefficients of the base vectors so you get a valid linear combination.
Now the coefficients exist if the integrals that derive $a_0$, $a_n$ and $b_n$ exist. But when I evaluate the integral to find these coefficients its doesn't matter what I choose as the bounds for the integrals as long they go from some $-L$ to $L$. You always get the same formula for $a_0, a_n$ and $b_n$ regardless of what $L$ you choose because most of the integrals become zero. Which means I should be free to choose whichever L I want.
This, in turn, should mean that I can take any function $f(x)$ and represent it as a linear combination of my base functions of sines and cosines and it will work regardless of what L I choose when I find the coefficients, or should it? I don't really know? Why does L have to correspond to the period of $f(x)$, why is even the period of $f(x)$ of any importance?