The space of periodic $L^2$ functions (say with period $2\pi$) forms a Hilbert space. (Here $L^2$ means that $\int_0^{2\pi} f(x)^2 dx$ exists.)
The inner product of two functions is given by $\int_0^{2\pi} f(x)g(x) dx$. (Here and above I am thinking of real-valued functions; for complex valued functions the formulas are similar.)
Now we consider two facts, one about $L^2$-functions, and one about Hilbert space
Every $L^2$-function can be expanded as a Fourier series.
Every Hilbert space admits an orthonormal basis, and each vector in the Hilbert space can be expanded as a series in terms of this orthonormal basis.
It turns out that the first of these facts is a special case of the second: we can interpret the trigonometric functions as an orthonormal basis of the space of $L^2$-functions, and then the Fourier expansion of an arbitrary $L^2$-function is the same thing as its Hilbert space-theoretic expansion in terms of the orthonormal basis.
Summary/big picture: To see how a "vector construct" like Hilbert space relates to Fourier series, you don't consider a single function in isolation, but instead consider the entire vector space of $L^2$-functions, which is in fact a Hilbert space.