We prove how the universal enveloping algebra constructions for Lie-Rinehart algebras and anchored Lie algebras are naturally left adjoint functors. This provides a conceptual motivation for the universal properties these constructions satisfy. As a supplement, the categorical approach offers new insights into the definitions of Lie-Rinehart algebra morphisms, of modules over Lie-Rinehart algebras and of the infinitesimal gauge algebra of a module.