Dog behaviourist/trainer here...
You are absolutely spot on to keep your kid out of homes with dogs whose needs are not properly being met - any dog. There is a direct correlation between dogs owned by people who fail to meet their needs, fail to understand a dogs needs, and dog attacks particularly on visitors.
As for a loose dog approaching you.
Stand still, folded arms, do not stare.
If you can slowly back away, do so, do not run.
If you have food on you, throw it away from the direction you want to go in, but still move slowly, back away rather than run.
Unfortunately it would be wholly unethical of me to tell you that there is any magic way to stop an attack in progress. There isn't and anyone telling you there is is a fantasist and a liar.
There are a number of techniques that might work however every single one of them will also put you at risk and may well not work, in fact may make matters much worse.
Remember, most dogs do not want to hurt you - there are over 12M dogs in the uk, proportionate to their numbers, very very few attack people. Some don't care about you at all, some are curious, some want to play - the above tactics with these dogs will help keep you safe.
Some of these XL bully attacks appear to have started in confusion and over arousal/excitement (chasing, grabbing at sleeves, very typical over aroused (1) play) rather than predatory or aggressive behaviour and have then tipped over into predatory/aggressive behaviour as people run/kick/hit/scream - it is possible to prevent that 'tipping' happening... by doing the above. You certainly won't make a situation worse by doing the above.
Some of them are likely to have been triggered by fear - these are the attacks that have happened inside peoples homes rather than out on the streets.
(1 - 'play' in this context is not necessarily 'sweet and innocent Disney cartoon fun. Dogs play to practice a variety of behaviours including predation and killing. A dog may play without intent to hurt, but if the 'toy' in their play is a human and the dog is very big, that human can still end up dead. However a dog who is intending to play can be potentially stopped. A dog intending to predate probably cannot if big enough/heavier than their victim).