Mid- and far-infrared luminosity functions and galaxy evolution from multiwavelength Spitzer observations up to z ~ 2.5