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.