Consider the following problem for a vibrating string:
$$ u_{tt}=c^2u_{xx}, \quad u(0,t)=u(L,t)=0, \quad u(x,0)=f(x), \quad u_t(x,0)=g(x) \tag{1} $$
Applying the method of separation of variables and using the boundary conditions, we obtain that
$$ u_{n}(x, t)=\left[A_{n} \cos \left(\frac{n \pi c t}{L}\right)+B_{n} \sin \left(\frac{n \pi c t}{L}\right)\right] \sin \left(\frac{n \pi x}{L}\right) \tag{2} $$
Applying now the first initial condition,
$$ u(x, 0)=f(x)=\sum_{n=1}^{\infty} A_{n} \sin \left(\frac{n \pi x}{L}\right) \tag{3} $$
If $f(x)$ is a periodic function of period $L$, then its Fourier series expansion would be given by
$$ f\left(x\right)=\frac{a_{0}}{2} +\sum_{n=1}^{\infty} \left[a_{n} \cos \left(\frac{2n \pi x}{L}\right)+ b_{n} \sin \left(\frac{2n \pi x}{L}\right) \right] \tag{4} $$
However, equations (3) and (4) do not coincide because of the $2$ factor within the sine of (4).
How could we relate expressions (3) and (4) to obtain the coefficients $A_n$? Should we assume that the period of $f(x)$ is $L/2$ instead of $L$?
The thing you have to keep in mind is that a regular Sturm-Liouville problem gives you a complete orthogonal set of eigenfunctions. So the Fourier expansion of any function $f\in L^2[0,L]$ will converge in the $L^2$ sense to $f$.
For the case at hand, the solutions of $$ f''=\lambda f,\;\;\; f(0)=f(L)=0, $$ are constant multiples of the following: $$ \sin\frac{n\pi x}{L},\;\; n=1,2,3,\cdots. $$ These functions automatically form a complete orthogonal basis of $L^2[0,L]$. In particular, the following holds for all $g\in L^2[0,L]$: $$ g=\sum_{n=1}^{\infty}\left[\frac{\int_0^L g(x')\sin\frac{n\pi x'}{L}dx'}{\int_0^L\sin^2\frac{n\pi x'}{L}dx'}\right]\sin\frac{n\pi x}{L} $$ The expansion holds in the $L^2$ sense, but not necessarily at every point, because changing the values of $g$ on a set of measure $0$ does not change the Fourier series given above. You do not have to try to relate this series to any other Fourier expansion. It's guaranteed to converge in $L^2$ to the function $g$.