Most dogs give warning signals, calming signals, etc before they escalate to a growl, snap, or full on bite.
I would really suggest ASAP that you study up on how to read your dog's body language so that you can see when your dog is feeling stressed and may be more prone to snapping.
Watch for liplicking and excessive yawning, for example, when kids are interacting with your dog. Is your dog turning his face or entire body away when kids approach? These can be signs of stress.
Your kids are old enough to learn the signals, too, if you teach them. And then make sure they respect your dog's signals. And your kiddos' friends must respect your dog, and if not then simply have your dog go to a nice cozy safe space with a toy or chewie if kids are visiting. At least for now til you work on what is going on.
You can easily and for free read up on dog body language/calming signs online.
A dog that is giving off calming or stress signals to a person and gets constantly ignored will start escalating his actions by ramping it up until the stressful person or trigger backs off.
A dog that is punished for growling can learn to go straight to the bite if his warning system has been taken away.
Prevention is key. If you know your dog gets cranky when tired give him space alone to relax. No kids (or adults) annoying him. My puppy gets cranky and plays "bitey" when she is overtired. We gently ask her to go to her crate and give her a chewie to reinforce that her crate is not punishment ever, but rather a safe nice place to go relax. Shortly after she is crashed out snoring. Problem alleviated, no chance for pup to mess up.
And since your dog is exposed to children, for everyone's safety I recommend, like others here have said, to contact a qualified behaviorist. Please ask the behaviorist (not trainer) lots of questions, be fully honest with them about the aggression events, and make sure they are using positive reinforcement and not fear, intimidation, force, or shock collars in their training.
Wishing you all the best and please keep us updated