Your assumption that each oscillatorsoscillator acts on a different Hilbert space is incorrect. Two different operators can act on the same Hilbert space.
In this case, the two operators defining the two different harmonic oscillators act on the same Hilbert space. The complete set of eigenfunctions of any of these operators, form a complete basis for this space. Any state belonging to this Hilbert space can be expanded into either basis set. The basis functions themselves are also part of this Hilbert space and thus one set can be expanded into the other set. The expansion coefficients and change of basis transformation can be found by calculating $\langle n_g|n_e\rangle$.