cause your parents has a hidden hair color gene.
Let's say your both parents' hair is black.
Gene for black could be: BB, Bb, bb, Bx, bX, or bx, where X and x is the other hair colour gene.
Your parents have black hair, so their B gene is dominan (we use capital B for dominan gene)
Their gene are BB, Bb, or Bx
Because you have different colour, so your parents gene must contain an x.
Then, your parents' gene is a Bx
If you combine two Bx, you could have:
BB = black hair
Bx = black hair
xx = different hair colour, which is YOU.
That's why genetically you can have different hair colour than your parents.