I will let the experts chime in here. But here are my two cents.
Your dog is displaying fear, which is not healthy. Since the dog is relatively new to you, that is good, in that you are the new master and can lay down a good foundation. I'll be interested to see what the experts add here.
For me, though, if my dog was doing that, I would do the following:
- Start a training regimen, both on leash (on walks) and off leash in your yard. You've got to get the dog in the habit of listening to you, trusting you, responding promptly and being rewarded (can use food or a ball first, then transition to praise)
- When you come up behind another dog (say, 20-40 feet), do not yank on the leash, change your breathing or give any indication anything is different. Just go through your training regimen, taking your dog's focus OFF the other dog and ON you, without changing direction or avoiding/approaching the other dog. Ignore them, but keep pace.
- In the initial stages, once your dog has gone through the regimen and taken their focus off the other dog, THEN change directions in a relaxed mode, keeping your dog focused on you with praise.
- Work up to longer periods behind other dogs, meaning that you keep the training regimen (stop, sit, down, stay, come), and then keep walking along after the other dog for longer periods of time (neither avoiding or approaching).
Also, please don't think you have to have the goal of your dog making friends with other dogs. Your goal should be that your dog pays no mind to them, not bothered in the least.
Myah does great at ignoring other dogs, though it's always a work in progress. By that, I mean that you don't reach the destination of training, but always have to keep it up.
With Myah, she was fearful as a young pup (just normal puppy fear, as she is of very sound mind!). Whenever we went places, if there was a loud commotion, dogs barking through a fence, noisy construction, a dog on a leash far off giving her bad vibes, etc, I just made her SIT and would instantly reward, acting like nothing was a big deal. Staying very relaxed myself. Only when she would relax (which could be a few or several seconds), would we then casually go another way.
Trust is a big issue. You need your dog to trust that WHENEVER they are on a leash with you, if they do what you ask, they will be safe and secure, bonded with you.
It's good that you ask this, because when the dog starts making their own fearful decisions, then you have a BIG problem.