Scattering theory of topological insulators and superconductors