Most puppies, even socialized, happy youngsters that never undergo traumatic events, go through shy/fearful stages called "fear periods" between 2 months and 6 months of age when they are exploring our noisy, busy world full of new sights and sounds. It's normal for an ordinarily confident pup to go through times when something or someone that they weren't afraid of yesterday becomes terrifying today. There are the expected stressful times such as when a pup is separated from their litter to go to a new home. There are the unexpected times too. Perhaps when a pup was happily walking down the sidewalk with his human and a jogger unexpectedly came up behind him and a nearby truck horn went off at the same moment so that he associated the sudden appearance of the jogger looming close-by with terrifying noise and now is scared of all joggers. Working through a pup's fear doesn't require knowing what incident (if there was one) started it, though if you can identify triggers (garbage truck coming down the road) it can help, adjusting your pup's emotion reaction just requires patience, focus and positive reinforcement to get the pup through the fear and back to a happy place.
It's important to understand that dogs are pack animals and rely on other members of the pack for confidence, protection and companionship. In order to build a puppy's confidence and help them join "your" pack, you have to gain that pup's trust, teach him that you will keep him safe, and that requires repetition. You are changing the pup's emotional response to a stimulus and you must take your time and not push too hard, too fast, or you could just make everything worse. And, never push him into situations where he may feel the need to protect himself by biting.
Let's get started. The first step, before you ask your pup to do something, is to get the pup to not see you as a threat but as a friend he can trust. If he sits in a corner, cowering and looking watchfully at you or perhaps not making eye contact, get down on the floor with your side to him (full frontal is a threat position in dog-speak). Making no eye contact, talking in a quiet reassuring tone, toss tasty treats to him (I prefer little bits of turkey or chicken). If he won't take the treat, then the stressor is too high (you're too close) and you need to back off a bit. As the pup becomes more comfortable, realizing that you can be trusted, toss the treats closer to you until the pup comes up and takes them from your hand. When he seems comfortable, put a leash on him and you're ready for the next step.
Challenge the pup with just enough pressure on the lead to get a movement or effort in a forward direction then immediately release the pressure and reassure with your voice ("Good boy"). (You can see this in Cesar's video below) Rest a second and repeat for another move forward and so on until he's walking forward. Be patient and reassuring for him so that he continues to trust you and trust that you won't hurt him. The goal is to get him out of his corner and into a different environment...another room or outside if possible. A small, safe, enclosed environment or play yard, perhaps with a friendly dog to see, would be perfect. Leaving the leash to be drug around by the pup, get down on the ground and again play the toss the treat game until he's eating from your hand. Enlist family and friends to sit with you in a circle, talk quietly, matter-of-factly ignoring the pup, while all the while everyone feeds the pup treats as he goes from one to the other investigating and learning that people bring good things...treats...and aren't scary after all. Perhaps he can relax and even wag his tail.
As soon as you have a bond with your pup and he trusts you to keep him safe, begin some obedience training. Start with basic sit, down, stay, watch me and come using motivation of food, praise, petting etc. With all these successes, your pup's confidence will grow and his trust in you increase.
Spend lots of time with your pup snuggling on the sofa, hand feeding him dinner and giving him daily massages. Through his experience with you, you're telling the pup, "let's move forward together, build friendship together, build confidence together". As your pup becomes pack-oriented again, he knows if he follows his human, his feelings of fear go away and is replaced with confidence.
(Remember, the goal is a confident pup, not a pup that's extremely needy and 'runs to mommy' every time he gets scared. Don't constantly caress and soothe your pup when he demonstrates extreme shyness or you are only reinforcing the behavior. I realize it's hard to ignore your shy, scared pup when he needs you, but if you want to change his behavior and help him become a brave and social animal, you will have to ignore unwanted behavior and reward wanted behavior.)
Every pup is different just like every child is different...some are more sensitive and cautious than others...some braver. A dog who became shy because of experiences may overcome that shyness but will probably retain some of the learned fearfulness. It's important to be aware of your dog's natural and normal (for him) behaviors and manage him and his environment to keep him safe. Building that bond with your pup and helping him be his best self is a lifelong commitment that is well worth every moment spent.
Here are some videos to help with human confidence building in the training process and to prepare you with knowledge. Some of these are extreme cases as they are adults, but the process is similar. So, please take what you can to apply to your situations.
Below is a video with some useful tips from Cesar Millan on helping a dog build their self-confidence.
Here's Frania Shelley-Grielen's method in words...
Or you can try some T-touch to release fear...
Handling exercises with clicker reinforcement...
These are extreme examples of two shy, really fearful dogs in a shelter. By following the steps similar to those outlined above, this handler helped this dog learn that humans aren't a threat... which opened up a whole new world of possibilities for them.