Dogs bark at strangers or noises as a form of communication. They may perceive strangers or unknown noises as a potential threat to their territory or family group. Barking is a way for dogs to alert their owners and to express their discomfort or unease in a particular situation. It can also be a natural instinct for dogs to alert their pack or family members of any potential danger.