The co-evolution of galaxies and their surrounding environments in massive galaxy clusters