Studies of distant galaxies have shown that ellipticals and large spirals (Schade et al. [CITE], ApJ, 525, 31; Lilly et al. [CITE], ApJ, 500, 75) were already in place 8 Gyr ago, leading to a very modest recent star formation (Brinchmann & Ellis [CITE], ApJ, 536, L77) in intermediate mass galaxies ( ). This is challenged by a recent analysis (Heavens et al. [CITE], Nature, 428, 625) of the fossil record of the stellar populations of ~105 nearby galaxies, which shows that intermediate mass galaxies formed or assembled the bulk of their stars 4 to 8 Gyr ago. Here we present direct observational evidence supporting this findings from a long term, multi-wavelength study of 195 intermediate mass galaxies, mostly selected from the Canada France Redshift Survey (CFRS). We show that recent and efficient star formation is revealed at IR wavelengths since ~15% of intermediate mass galaxies at are indeed luminous IR galaxies (LIRGs), a phenomenon far more common than in the local Universe. The star formation in LIRGs is sufficient in itself to produce 38% of the total stellar mass of intermediate mass galaxies and then to account for most of the reported stellar mass formation since . Observations of distant galaxies have also the potential to resolve their star formation and mass assembly histories. The high occurrence of LIRGs is easily understood only if they correspond to episodic peaks of star formation, during which galaxies are reddened through short IREs (infrared episodes). We estimate that each galaxy should experience 4 to IREs from to , being the characteristic timescale. An efficient and episodic star formation is further supported by the luminosity-metallicity relation of emission line galaxies, which we find to be on average metal deficient by a factor of ~2 when compared to those of local spirals. We then examine how galaxy IREs can be related to the emergence at high redshift of the abundant population of galaxies with small size (but not with small mass), blue core and many irregularities. We show that recent merging and gas infall naturally explain both morphological changes and episodic star formation history in a hierarchical galaxy formation frame. We propose a simple scenario in which % of intermediate mass spirals have recently experienced their last major merger event, leading to a drastic reshaping of their bulges and disks during the last 8 Gyr. It links in a simple manner distant and local galaxies, and gives account of the simultaneous decreases during that period, of the cosmic star formation density, of the merger rate, and of the number densities of LIRGs, compact and irregular galaxies, while the densities of ellipticals and large spirals are essentially unaffected. It predicts that 42, 22 and 36% of the IR (episodic) star formation density is related to major mergers, minor mergers and gas infall, respectively.