If you have a dog that can switch at any time e.g. without an obvious stimulus it's a dog that should be put down.
It wasn't socialised properly and didn't learn how to behave around kids and other dogs, or has a neurological condition.
Even dogs with breed characteristics of aggression...