Most family dogs will just roll over for belly rubs once the burglar is inside, but the barking is a great deterrent because it draws attention. The burglar has no idea if that is normal or not, and if someone else might hear it and come investigate.
In this spirit, I remember an ex-burglar on reddit saying that small dogs are the best guard dogs, because big ones typically have to be trained to be nice, but small ones just don't shut up.
Actually, I wonder why the consistent barking is more easily trained out of bigger dogs than smaller dogs. Anecdotally, my big husky rarely barks (usually only during play, or when "talking" with us), but my small shiba will never shut up if she hears a noise at the door.
For all dogs barking is a defense mechanism. As the bigger dogs grow up, there are less things that they find threatening, whereas the small dogs always feels threatened because most things are a lot bigger than they are.
Also, in my anecdotal experience, large dog owners end up putting in more training time because the consequences of not are much greater.
My 50lb, German shepherd looking village dog jumps on grandma? Grandma breaks a hip. My parents 3lb Shit-Poo jumps on Grandma? Cue the cooing.
Similarly with barking. Not saying it's true for all owners, but generally once you start training alot of other behaviours get cleaned up as a side effect.