Hair, is essentially an extension of one's skin. It is a material made up of tiny filaments that starts from the part of the skin called the dermis. Hair, is colored by pigment, a light absorbing material. In humans this pigment comes from 2 types of melanin. This pigment, is formed in the hair follicle. The two types of pigments are called Eumelanin which gives hair its "darker" features and pheomelanin which gives hair a "red" feature. When these pigmentations alter in depth of color they provide us with our hair color.
Generally, all humans will develop grey hair by the time they turn 40, some earlier and some later. The grey hair stems from lack of pigment formation. Our hair color is generally dictated by the amount of pigment that the hair follicle produces. The trigger for this pigment production is largely genetic, what we have inherited from our ancestors. Hair color is not generally stress induced and there is no true way to avoid it. Alternatives to greying hair are coloring products and avoidance of sun which could damage the hair. Before you partake in any of these behaviors you should contact your primary care physician