The ALMA Spectroscopic Survey in the Hubble Ultra Deep Field: Implications for Spectral Line Intensity Mapping at Millimeter Wavelengths and CMB Spectral Distortions