Why does the hair color of some babies change when they get older?

Normal. Newborns often can lose their whole head of hair (due to decreasing hormones)- but don't worry- it will grow back. And when it does it may be a different color, texture, etc. This is all normal.
Genetics. As the baby grows, various genes get activated while others may get inactivated. It's the change in the millions of gene activation/inactivation that leads to changes as the baby matures. It is natural and is part of natural growth.