Most Helpful Guys
A dog barking (apart from the hyper sort of barks) represents the dog saying something about what he/she perceives as a threat. Hence, a low under-the-breath “ruff” is like the dog saying “there is possibly a threat,” while a loud in-your-face bark is like “threat detected!” This is also why if someone comes over often and the pets the dog/gives it food, the dog will stop barking at the person after awhile.
Dogs bark at some people and not others because the situation is often different which affects the perceived “threat level.” For instance, a dog may not bark much at someone who the owner brings in all friendly like. However, a dog will often bark quite aggressively at someone who appears to be sneaking in and hasn’t made their presence known. Even things like whether the person is staring the dog down or not makes a difference. For instance, my dogs become quite paranoid if you look at them too long lol. There are other factors too, such as whether the dog is on home turf or not, if the dog is with other dogs, where the owner is, the state of the dog before the person comes by, etc..
They have real good vibes about certain people they can tell if your crooked or a good person
Most Helpful Girls
Probably location more than anything (if it's a stranger)
My mom's dog will get tense if it's night time/dusk and a person is approaching whereas if it's daylight, he's way more relaxed.
Also, if the person walks up to me/my mom and we don't know them, our defenses are up so the dog can interpret that.
Also, the person's body language/gender.
My mom's dog can go from staring down a strange guy to licking all over a random woman in the same day.
Dogs can sense something that makes them feel uncomfortable and/or feel in danger. That prompts them to bark in a disturbing manner as warning for themselves and/or others they care about.