What causes certain LEGO parts to yellow over time, and how can this be prevented?
There are many things such as dirt and chemicals that can cause elements to change color. Dirt can easily be washed off, but certain contaminants such as cigarette smoke can stain plastic.

The most common issue that causes LEGO bricks to yellow is interaction with ultraviolet light, most commonly from the sun. The simplest way to prevent this is to store parts indoors out of the way of even indirect sunlight.

There are some tips for correcting this issue in another question, and more details about the chemical process that causes UV light to degrade ABS over on Chemistry.