The rules of interacting with strangers are different when the stranger is walking a pet dog.
It’s generally considered acceptable to initiate a conversation in order to compliment someone on their dog or ask certain questions about the dog. (Infodumping about dogs is *not* considered acceptable, and criticizing their approach to their dog is considered rude).
It’s also generally considered acceptable to ask if it’s ok to pet the dog. Keep in mind that sometimes the answer will be no, and act in ways that make it clear that you understand this. Do not make any move to pet the dog until you have been told that it is ok. And if it is ok, make sure to approach the dog carefully. Let the dog smell your fingers first, then pet the dog if it seems to be ok with the dog.
If someone is walking with headphones, that is a signal that they would prefer not to be approached. Don’t initiate a conversation with them unless you have a solid reason to believe that they would welcome it. (A desire to flirt with them is *not* such evidence; neither is having had dog conversations with that person in the past, neither is their apparent awareness that you are present).
The rules for service dogs are different. Service dogs are not pets, and being out with a service dog is *not* an implied invitation to pet-related social interaction. Service dogs usually wear either harnesses or vests. If you suspect that a dog is a service dog, err on the side of assuming that it is one. You should not approach or interact with a person with a service dog unless it would be appropriate to interact with them if they did not have a service dog. Especially, you should not attempt to interact with the dog; it’s rude and distracting a service dog can can someone injured or killed. You should not ask to pet the dog — the answer is almost certainly no, but someone might be uncomfortable asserting that. Asking to pet a service dog is a microaggression. (All of this is assuming that you don’t have a service dog or a disability relevant to service dogs. I don’t know what the rules are about interactions between people who both have service dogs.)
HAHAHA I WAS LIKE THIRTY BEFORE I FIGURED THIS SHIT OUT.
I rarely even look at the person, I just go for the dog if it comes near me. I don’t want to talk to the person. I just want puppy loves. Sigh. I need to work on this.
Sometimes that’s ok (it’s never ok if the dog is a service animal), but you have to be good at reading human and dog body language in order to be sure it’s ok with both of them.