You can think of light as a wave, with peaks and dips. The distance between 2 peaks is called the wavelength. Different colours of light have different wavelengths – blue light has a shorter wavelength than red light.
When light is moving towards you the peaks get squashed up so it gets bluer. When it’s moving away from you the peaks get stretched out so it looks redder.
This is how we know that the universe is expanding, because far away galaxies emit redder light. It’s very useful for working out how fast things are going!