mordin+harry
There are laws of magic, what things work, what can't work. For instance, you can't just create food out of thin air. It's impossible. But you can multiply it if you already have it, and you can summon it, if you know its location, and you can transform it from one thing into another. But that's just regarding transfiguration. There are laws that dictate how making an antidote to a poison works, all sorts of things.
Genetics might have something to do with it, but the thing is, there are people who don't have anyone magical in their family, and then suddenly they come along, able to do magic. And even in magical families, there are people who pop up who can't do magica at all. Neville's family thought he was a squib for the longest time.