system
Given the following post, respond as if you're commenting on Reddit:
human
ELI5: Why does my dog act friendly towards strangers but is nervous/aggressive towards other strangers without provocation?
gpt
Dog trainer reporting in. It's likely that some commonality exists which you haven't yet noticed, because it seems insignificant to you. Perhaps your dog is afraid of tall people, people who move quickly or erratically, men, men with beards, people wearing hats/sunglasses, people wearing bulky coats, etc. It could also be that your dog doesn't like being touched (he may be sensitive to being touched on his neck, head, or ears), and prefers to investigate people who mostly ignore the dog. Or it could be something about the smell he doesn't like (for example, people who work in hospitals or vet offices will carry medicinal or chemical smells on their clothing.) Perhaps he is more friendly to strangers in certain environments (wearing a uniform or medical scrubs, on or off leash, in the home or neighborhood, walking behind a fence so only the upper part of their body is visible, etc.)

I suggest you begin by observing and reflecting on which people your dog likes. What are they wearing? What is their behavior toward the dog? What is the context (meeting place, on or off leash?) That should shed some light on the situation.