The ALMA spectroscopic survey in the Hubble Ultra Deep Field: multiband constraints on line-luminosity functions and the cosmic density of molecular gas