The color changing ability is caused by distribution of melanin (color pigment) in the scales. There are 3 different types of color producing scales (chromatophores) which is why you see such variation. Xanthophores are the most superficial layer and are responsible for yellow and red. Melanophores are under those and responsible for black. Guanophores are the deepest and reflect blue light. When the melanophores have evenly distributed melanin your cham appears darker, and when it's concentrated in one focal area it allows the other colors to be more prominent. (referenced from Necas' "Chameleons - Nature's Hidden Jewels")
Based on their mood and environment the melanin can be widely distributed throughout the scale, causing one color, or very concentrated in one spot or at the surface of the scale, causing a different color. It varies their mood and environment. A constantly dark cham may indicate chronic stress, fear or illness. Whereas a light colored cham may mean contentment. And the super brightly colored chams may be breeding colors or a method of intimidation (when my veiled is the brightest).
Necas also mentioned in one of his books that chameleons raised around dark colors that might not appear in their native habitat (like reds) may actually cause them to have darker colors as adults than babies raised around a lot of green, which I thought was interesting.