While I know it's not always the most ideal situation while hiking, you really should keep your dog leashed. When I first started seeing dogs on the trail, I'd often see them running free, and never really though of the problems with this till I started planning how to trail my dog for the trail.
I realized that there are just so many reasons to keep your pet on the leash: for your comfort, for other people's comfort, for your dogs safety, so your dog doesn't harm any animals, so your dog doesn't get lost, the list goes on.
Not only that, but letting your dog roam free by nature goes against Leave No Trace hiking principles, which I hope most of you would be committed to keeping. @treedweller has been teaching a lot about why we need to watch the environment, and I hope that this tip can help some people understand why keeping your dog on a leash is part of that!