Here's how it works: imagine a bug is sitting in the center of a pond and two observers, observer A and observer B, are sitting on each side of the pond. If the bug moves its feet once per second, it will create tiny waves in the water that will move out in all directions. Each wave will reach both observers at the same rate. But if that bug starts moving toward observer A, everything changes. Now the waves reach observer A more often—or at a higher frequency—as the bug approaches. At the same time, the bug is moving away from observer B, causing the waves to reach it less often, or at a lower frequency.
That's why you hear a siren drop in pitch as it moves away: the sound wave is dropping in frequency. This works with light waves too, except instead of lowering in pitch, a lower-frequency light wave is perceived as lower on the electromagnetic spectrum. In the visible portion of this spectrum, red light has the lowest frequency and blue light has the highest. Therefore, when an object is moving away from us in space, the light waves that reach us appear red—or, as an astronomer would say, they're redshifted. The redshift of faraway galaxies is how we know they're moving away from us, and, therefore, that the universe is expanding. Learn more about the Doppler effect in the videos below.