Ah yes, the infuriating dog without owner scenario. This is one least favorite things to deal with on the trail and only gets worse if I have my leashed dog with me, since I then have to deal with controling both my dog and the one that is unattended.
I have no perfect way of dealing with it, but what I typically do when a strange dog approaches me on trail without a visible owner I call out something such as "Git!" this usually causes them to run back to their owners and solves the problem before it starts. Most dogs know enough to reapond to a firm "No" or often just a hand held straight out in the universal "stop" signal. If andog does approach me my default is to place my hiking poles between the dog and myself, not in a threatening manner, I simply put the tips in the ground in front of me and hold them much in the same way I would if I stopped for a moment to rest. This creates some space between myself and the dog, plus dogs are smart enough to know that by doing this I'm giving them a signal that they should not approach me. This techniques is great because it stops friendly dogs from jumping on me in additon to keeping potentially fear aggressive dogs away.
You are correct to never assume a dog is friendly. It is important to understand that dogs are creatures of habit and do not generalize well; a dog that is not used to being in the woods or encountering strangers by itself can become both stressed and defensive in this situation, even if it is normally a very friendly in everyday life (an important point that many irresponsible owners fail to understand.) I've gotten to the point where I don't let a dog approach me on the trail until after I have met and spoken to the owner.
Regarding the people who say "Oh, he's friendly" I respond by saying "Yeah, he's also not under control."
Unfortunately dog parks really aren't the great idea that people think they are and are likely somewhat of a fad. Dogs are pack animals that thrive when they are around dogs they know with an understood dominance hierarchy. My dog's trainer refers to dog parks as "the most unnatural situation you can possibly put a dog into." Sadly injuries, dogfights, fights between angry owners, and resulting lawsuits are all fairly common at dog parks. I used to go to the one in New Canaan a decade ago and witnessed all of these things happen. The public New Canaan dog park has since been transformed into what is effectiy a members club because of these problems. They have locked the gates and you are not allowed access until you sign up and your dog has been approved by a formal process.p.s. My town has done the fund-raising for and is now opening a dedicated dog park, where all the dogs can play together and run free. This strikes me as a very sensible and good solution.