Why do distant galaxies have different colors than closer ones?
Galaxies come in a range of colours, but more distant galaxies appear redder than nearby galaxies.
First, a bit of background on how galaxy colours are measured. We take a picture of the galaxy through a filter that only allows a specific colour of light through. There are a bunch, suppose we use the 'g' filter (g for green). This tells us the total magnitude (sort of like brightness) in the g-band. Then we take another picture of the galaxy, suppose we use the 'r' filter (r for red), giving the magnitude in the r-band. Then the two magnitudes are subtracted, giving what's called the (g-r) colour. Because of the way magnitudes are defined, higher values of (g-r) correspond to redder colour, which is a bit counter-intuitive. So now we know what colour the galaxy appears to be, but this may not correspond to the colour that the galaxy actually is (as it would appear to someone near the galaxy).
To determine the actual colour, the spectrum of the galaxy is observed. A spectrum measures the intensity of light across a range of frequencies. Different elements/chemicals absorb or emit light at specific frequencies, which appear as bright or dark lines in the spectrum. By measuring the space between lines, we can figure out which lines correspond to specific transitions of particular elements/chemicals. We know what frequency the lines should occur at because we can measure them in a lab on Earth, but for a distant galaxy the lines are all moved to lower frequencies (i.e. they are redder in colour). In this way the amount of reddening, or redshift, can be quantified.
Redshift can occur for a few different reasons, one of which is the Doppler effect. The idea is the same as when a siren on a vehicle moving toward you sounds higher pitched than when it is moving away from you. The light is reddened, so we conclude that distant galaxies are moving away from us.
Edwin Hubble noticed that the further away a galaxy is, the redder it is, and so the faster it is moving away, according to the relation:
This is a key piece of evidence telling us that the Universe is expanding.