Hair color just like eye color has a large genetic component. Some people that turn gray do so because this gene runs in their family. A pigment called melanin determines hair color just as it determines skin color. In hair this pigment is found in the hair follicles. As we age, the pigments fade because the pigment cells in the hair follicles die. Then the hair shaft (visible part) turns gray due to a lack of melanin.
Technically, the hair that is colored brown, red, or blonde does not "turn" gray, rather it falls out. When new hairs grow in, they are gray because of the loss of pigment.
Some people tend to think that things like stress will change the hair to a gray color. This is not entirely correct, stress doesn't really cause the color change, but stress may speed up the normal aging process, this aging process is what causes the change in hair color.
Gray hair can occur at any age. It is commonly thought that people get gray hair as they age but people can get gray hair in their teens.
Cells in our hair follicles are called melanocytes. They produce pigments which are called melanin. Melanin is what give our hair color. The more melanin that is present in our hair, the darker it is. When melanocytes stop producing pigment, the hair appears to turn gray. It is actually more transparent than gray.
The main reason that people get gray hair is because of heredity. If your parents turned gray, especially at an early age, chances are you may get hair as well. In addition, as we get older the melanocytes produce less pigment.
Hair gets its color from melanin. This is produced by cells by the base of hair follicles. As people get older, the cells stop producing melanin, though scientists are not sure why--the building blocks are still there, but melanin is no longer produces. When this happens, the hair growing out of that follicle is no longer brown, red, black, blonde--but gray. This happens at different ages to different people, and is under genetic control. My own grandmother still had brown hair at 90, while a great aunt had white hair in her thirties.
"Guilty" of this fact is the massive accumulation of hydrogen peroxide that causes the gray color of hair.
This substance, known mainly as hydrogen peroxide (H202), is used in low concentrations for hair discoloration, before hair coloring. Some cells produce a reasonable amount of hydrogen peroxide, but along with age, the secretion is increased.
Researchers made the discovery while analyzing cell cultures of human hair follicles (saccate anatomical formations surrounding the hair root). Thus, they found that the accumulation of hydrogen peroxide is caused by reduction of an enzyme that breaks the hydrogen peroxide into water and oxygen.
To further complicate things, high levels of hydrogen peroxide destabilises, reaching to the disruption of the secretion of melanin in hair follicles. Melanin is the pigment responsible for hair color, skin and eyes. Bleaching effect of peroxide and diminution of melanin production are enatiling hair greying.