Context. Analytical models of chemical evolution, including inflow and outflow of gas, are important tools for studying how the metal content in galaxies evolves as a function of time.Aims. We present new analytical solutions for the evolution of the gas mass, total mass, and metallicity of a galactic system when a decaying exponential infall rate of gas and galactic winds are assumed. We apply our model to characterize a sample of local starforming and passive galaxies from the Sloan Digital Sky Survey data, with the aim of reproducing their observed mass-metallicity relation. Methods. We derived how the two populations of star-forming and passive galaxies differ in their particular distribution of ages, formation timescales, infall masses, and mass loading factors. Results. We find that the local passive galaxies are, on average, older and assembled on shorter typical timescales than the local star-forming galaxies; on the other hand, the star-forming galaxies with higher masses generally show older ages and longer typical formation timescales compared than star-forming galaxies with lower masses. The local star-forming galaxies experience stronger galactic winds than the passive galaxy population. Exploring the effect of assuming different initial mass functions in our model, we show that to reproduce the observed mass-metallicity relation, stronger winds are requested if the initial mass function is top-heavy. Finally, our analytical models predict the assumed sample of local galaxies to lie on a tight surface in the 3D space defined by stellar metallicity, star formation rate, and stellar mass, in agreement with the well-known fundamental relation from adopting gas-phase metallicity. Conclusions. By using a new analytical model of chemical evolution, we characterize an ensemble of SDSS galaxies in terms of their infall timescales, infall masses, and mass loading factors. Local passive galaxies are, on average, older and assembled on shorter typical timescales than the local star-forming galaxies. Moreover, the local star-forming galaxies show stronger galactic winds than the passive galaxy population. Finally, we find that the fundamental relation between metallicity, mass, and star formation rate for these local galaxies is still valid when adopting the average galaxy stellar metallicity.