In their evolution, star-forming galaxies are known to follow scaling relations between some fundamental physical quantities, such as the mass-metallicity and the main sequence relations. We aim at studying the evolution of galaxies that, at a given redshift, lie simultaneously on the mass-metallicity and main sequence relations (MZR, MSR). To this aim, we use the analytical, leaky-box chemical evolution model of Spitoni et al. (2017), in which galaxy evolution is described by an infall timescale $tau$ and a wind efficiency $lambda$. We provide a detailed analysis of the temporal evolution of galactic metallicity, stellar mass, mass-weighted age and gas fraction. The evolution of the galaxies lying on the MZR and MSR at $zsim0.1$ suggests that the average infall time-scale in two different bins of stellar masses ($M_{star}<10^{10} M_{odot}$ and $M_{star}>10^{10} M_{odot}$) decreases with decreasing redshift. This means that at each redshift, only the youngest galaxies can be assembled on the shortest timescales and still belong to the star-forming MSR. In the lowest mass bin, a decrease of the median $tau$ is accompanied by an increase of the median $lambda$ value. This implies that systems which have formed at more recent times will need to eject a larger amount of mass to keep their metallicity at low values. Another important result is that galactic downsizing, as traced by the age-mass relation, is naturally recovered by imposing that local galaxies lie on both the MZR and MSR. Finally, we study the evolution of the hosts of C$_{rm IV}$ -selected AGN, which at $zsim 2$ follow a flat MZR, as found by Mignoli et al. (2019). If we impose that these systems lie on the MSR, at lower redshifts we find an inverted MZR, meaning that some additional processes must be at play in their evolution.