I suppose it's defending its territory & is letting 'intruders' know that they are not welcome. It's an instinct thing from way back, to protect the dogs 'pack'.
The more senior the dog feels in the pack , the more it feels the need to jump in and take charge in defending (ie barking at strangers etc) If you don't want that behaviour in your dog you can change it by kind of demoting it in the family pack so it doesn't feel the need to take charge.
But maybe you don't mind the dog guarding you...it'd certainly put people off breaking in!