Galaxies as Probes of the Universe: From Dynamical Models to the Inference of Cosmological Parameters