Mode matching methods for spectral and scattering problems