Short of keeping a dog permanently locked away from kids, it's next to impossible to prevent all dog attacks. The attacks I've seen have always been so fast, that the adults on the scene couldn't react fast enough to stop it before it happened. It's not that they thought their dogs would never possibly conceivably turn nasty. It's not that they were being negligent or not paying attention. But dogs are dogs, and work by a different system of rules than us. And when you own a breed like one of the pitbull varieties, or a rotty, when they snap, it is disastrous.
I think it's a huge misconception that dog attacks never occur under a typical day with a dog. Animal lovers seem to think there's always a reason, when there is so often not.
There is almost always a reason a dog attacks unless it is just an unsound animal. And yes, unsound animals are certainly out there.
Like you said, dogs work from a different set of rules than we do. If you know the rules you decrease your chance of a dog bite to almost zero. I agree you can never completely guarantee you won't be bitten, but there is a reason a lot of people can work with "aggressive" dogs without ever sustaining a bite and others get a bite from the sweet innocent family pet. It's because those who work with "aggressive" dogs usually are a lot more careful with them and know the rules of dog behavior. My dad had bully dogs in the back for years (pitbulls, bull terriers, bullmastiffs, mixes of those breeds). Some of them were severely abused, most of them were poorly bred, yet none of those dogs ever bit him or any other human being. That wasn't just luck.
I have seen so many parents let their kids act improperly around dogs. The kids are running, yelling, grabbing at it, pulling on its ears, staring into its eyes, touching its food bowl, trying to take toys from its mouth or worst of all playfighting with their human friends in front of their dog. Children of a certain age are just naturally provocative to dogs. They should not be allowed around them until they are mature enough to respect the rules and dogs should not be allowed around children unless they know the hierarchy. That goes for any dog breed. Sometimes it does mean keeping the dog permanently away from the children. None of my dads dogs went to homes with children under the age of 12. I would have to get rid of my own dog if I had kids or keep him permanently separated from them unless I was in the room. I know that about him. If he ever bites a child, I'd have no one to blame but myself.