I’m a little surprised you were not more aware of the situation as it developed, and had not thought out how you might respond.
I’ve had dogs all my adult life. We walk our dogs very often in our community and on our travels. We pretty much expect every dog we encounter (and their owners) to be clueless and poorly behaved. My last dog had no problem ignoring other dogs, but disliked them getting in his face. So we had 11 years of “social distancing” our dog from others, and we encountered the entire imaginable range of dogs/owners - including poorly behaved/uncontrolled dogs lunging at and attacking us and our dogs. Come to think of it, neither of our previous 2 dogs were the overly playful sort as far as other dogs were concerned. They were more focussed on their owners. I often got a kick out of walking my old dogs off leash, when they would totally ignore some dog that was barking and lunging away on the other side of the street. Always got a kick out of it when the other owner would say something suggesting MY dog was doing something wrong! 
And we are in the general habit of declining to have strangers’ kids pet our dogs. We’re just generally not interested in having our dog entertain someone else’s kids. No matter how well-behaved my dog, I NEVER trust them thoroughly, and I SURE don’t trust a kid I don’t know.
Now, we have a puppy. And with the limitations imposed by this virus limiting “play dates”, we’ve been a little more tolerant of dog interaction on walks. Not interested in kids, b/c the pup still gets excited and could knock down or scratch a kid in his exuberance. But if I have my dog on a 6’ leash, and the other dog is on a leash, that ensures that the owners are >6’ apart.
I imagine this comes off as a little critical of you, and I apologize. But if I see an off leash dog, you’d better be sure that I do not lose awareness of where the dog is, and if it is approaching us, I have no qualms against calling out loudly for the other person to “Please control your dog. We are not interested.” Sometimes you have to repeat it, in raised tones. People are clueless idiots. That is just my default, so I never get surprised as you describe. I guess it would be more challenging if you sometimes allow your dog to play, and other times don’t.
Whenever a dog is approaching me and not sufficiently controlled, a part of me is always mentally prepared to kick the shit out of the dog should it cause problems. No, not if it just approaches and sniffs and play bows. But if an uncontrolled dog initiates a fight, I’ll do what it takes to stop it. I love dogs, I’m very comfortable around them, and I’m very good at reading them. But I’ve got no qualms against protecting me and mine from idiots and their poorly behaved dogs.