The ALMA spectroscopic survey in the Hubble Ultra Deep Field: CO excitation and atomic carbon in star-forming galaxies at z = 1-3