Does it ever seem like you don't exist to your dog in certain situations? Maybe there's another dog being walked nearby. A squirrel. A bird. A cat. Maybe there's a person walking by and they made eye contact with your dog, which is the universal signal to many young dogs that says 'Come on over'. There you are, calling your dog's name, "Fido! Fido! FIDO!!" and your dog is so distracted by the dog/squirrel/cat/whatever that it's as if his brain is magnetized to it. In a way, that's exactly what's going on. Young dogs tend to be very environment-oriented to begin with, and when something distracting comes on the scene, there is a critical distance where they switch from the thinking part of their brain to the reacting part. If you're too close to the distracting thing, your dog's attention is glued to the distraction like a magnet.
Knowing how much distance from distractions your dog needs in order to stay in the thinking part of his brain is very important. If you want to have a dog that can think and behave when around other dogs or people, or in busy situations, you need to start training at that critical distance. This critical distance, called behavioral threshold in dog training terms, is different for every dog and every situation. Determine how much distance your dog needs to be successful by asking for a simple behavior like sit. If your dog is too distracted to perform a simple behavior such as sit, he or she will have a very hard time performing more complex behaviors like leash walking with attention. Always move further away from the distraction and test again. Ask for another sit. If your dog can perform the behavior with relative ease, you are at a good working distance. (If your dog performs the behavior but still can't take his eyes of the distraction or responds slowly, move further away.)
Practice your desired behavior(s) (sit, stay, walk on leash, heel, come when called) at a distance where your dog can be successful. Remember, dogs learn best from successful repetition. Reinforce successful repetitions by rewarding your dog with his favorite food or toy. Keep your training sessions brief and fun.
Distance is the key to setting your dog up for success when he's around the things he finds distracting, and the great thing about this is that you'll be able to keep decreasing the distance as your dog improves. Every few successful repetitions, take a step or two closer to the distraction. Gradually move closer and closer. Getting too close to the distraction too fast will cause the behavior to break down.
It's a good idea to vary the distance by ping-ponging back and forth between greater and smaller distances with each repetition. Here's an example of what that might look like. Let's say the distraction is a person walking in the distance, and the desired behavior is loose leash walking. The behavioral threshold in this example will be 50 feet from the distraction. So, on the first repetition, you would ask your dog to walk with you for perhaps ten or fifteen steps at 50 feet away from the distraction. Do two or three more repetitions like this. That's four repetitions at a distance of 50 feet. On the next repetition, decrease to 48 feet. Do two or three more repetitions at 48 feet, then go back to 50 feet for a repetition or two. Next, decrease the distance to 46 feet. After two or three more repetitions, go back to 47 feet. End the session there, and go play with your dog.
There are some other steps you can take to support setting your dog up for success. Use your rewards. In most cases, food rewards work wonderfully (and are easy to fade out over time) but you can also use play, a chance to sniff, or praise. Reward successful repetitions of the desired behavior. If the situation is more challenging for your dog, be more generous with the rewards. Use a speedy pace if your desired behavior is leash walking or heel. Dogs have to pay attention to what they're doing when they are walking fast or running. That makes them less likely to fixate on the distraction. Make sure the behavior you are asking for is fun. Dogs will have a harder time with behaviors they find boring. You can make any behavior fun be being enthusiastic, and by pairing it with, or even making it part of a game.
When you have decreased distance to within a few feet of the distraction, the distraction itself can be a reward. For example, if the distraction is a person or another dog, as long as your dog can and does perform the behavior, you can tell him 'go say hello' and release him to greet.
Practice, be systematic about decreasing distance, and always reward good behaviors. Before you know it you will be able to get that desired behavior around distracting things and people will marvel at your well-behaved canine friend.