Please note that Harry Potter is a fictional story. According to
this story, wizards and witches (as the female wizards are called
in the Harry Potter story) usually inherit their magic from their
parents - though in some cases non-magical parents have magical
children, and vice versa.