Explanation:
This phenomenon is known as the Doppler effect and refers to the change in a wave perceived frequency (or wavelength=color) when the emitter of the waves, and the observer move relative to each other. For example, as a star moves away from the Earth, its espectrum turns towards the red.
This fact was discovered by the astronomer Edwin Powell Hubble, who observed several celestial bodies (including galaxies), and when obtaining the spectra of distant galaxies he found out the spectral lines were displaced towards the red (redshifted), whereas the nearby galaxies showed a spectrum displaced to the blue.
From there, Hubble deduced that the farther the galaxy is, the more redshifted it is in its spectrum and is a strong evidence of the expansion of the universe.