Scaling relations of metallicity (O/H), star formation rate (SFR) and stellar mass (Mstar) give important insight on galaxy evolution. They are obeyed by most galaxies in the Local Universe and also at high redshift. In a companion paper, we compiled a sample of ∼1100 galaxies from redshift 0 to ≳3, spanning almost two orders of magnitude in metal abundance, a factor of ∼106 in SFR and of ∼105 in stellar mass. We have characterized empirically the star formation ‘main sequence’ (SFMS) and the mass–metallicity relation (MZR) for this sample, and also identified a class of low-metallicity starbursts, rare locally but more common in the distant Universe. These galaxies deviate significantly from the main scaling relations, with high SFR and low metal content for a given Mstar. In this paper, we model the scaling relations and explain these deviations from them with a set of multi-phase chemical evolution models based on the idea that, independently of redshift, initial physical conditions in a galaxy's evolutionary history can dictate its location in the scaling relations. Our models are able to successfully reproduce the O/H, Mstar and SFR scaling relations up to z ≳ 3, and also successfully predict the molecular cloud fraction as a function of stellar mass. These results suggest that the scaling relations are defined by different modes of star formation: an ‘active’ starburst mode, more common at high redshift, and a quiescent ‘passive’ mode that is predominant locally and governs the main trends.