I apologize if this is more mathematical than physical, but this issue always seems to come up when I am solving physics problems.
Given a function of two variables $f(x,y)$ let us decompose it into an infinite series of orthogonal functions $\psi_n(x)$ such that $$ f(x,y) = \sum_n^\infty c_n(y)\psi_n(x) \tag{1}$$ and so $$ c_n(y) = \int_a^b \psi_n^*(x) f(x,y)\ dx\tag{2}$$
My question is simply how are we always allowed to decompose a function of two variables as the product of two variables (and then sum over varying products). Is there any sort of non-rigorous proof as to why this can always be done? I've used this fact many times, but I have never seen any explanation as to how/why we can so trivially separate them.