When socializing your puppy, take it at the puppy’s speed. If he wants to walk away from a person, go with him! He may just need a moment to regroup and build his confidence. It’s critical that puppies have good experiences as their own pace, not forced interactions.
Watch for body language while he’s being petted, like glancing away, turning his head, sniffing the ground, walking away, shaking off, or quickly licking his lips. If you see any of those, just happily say, “let’s go!” and walk a few steps away with the puppy. You can even hand out a treat at that point (for putting up with the stranger and for coming with you), and then possibly see if he wants to go back for more.
Do this with everything: other dogs, strangers, kids, garbage cans, etc. Let him check out scary stuff from what he thinks is a safe distance. The more he can trust you on the leash, the more brave he will be. And since most aggression is really just fear, now is your chance to do some aggression prevention.