Let me start like this, hair colour is determined by a particular chemical called melanin. Now every strand of hair stems from a hair follicle and every hair follicle contains a certain amount of pigment cells and these pigment cells are what produce melanin.
Now the thing is, the older we get the weaker our bodies become and thus the pigment cells begin to weaken as well and die. As the pigment cells start dying, the amount of melanin produced begins to reduce and as a result, the hair begins to lose its colour.
Due to the lack of melanin, the hair begins to turn gray or white and eventually just about all your hair will become like that. It's a natural process and cannot be avoided.
There is pigment found in the skin as well as the hair is referred melanin that is responsible for colour production. These melanin can be categorized into two forms: eumelanin (deals with the production of brown or black colour) and pheomelanin. As most people age, the begin to lose the melanin in their hair while some are able to retain small amount of these melanin. Grey hair is fundamentally hair with small amount of melanin, whereas white hair lacks melanin in totality. However, the control of genes play a very vital role in such cases. For some families, their members begin to grow grey hair at very young age- I even have friends of my age with grey hairs. The exact reason why the hair is able to lose these melanins is still unclear to many.