A.B.
The morals and values you teach your children stop them from caving into peer pressure when they have first, absorbed the lessons you've taught, and second, choose to listen to what you have taught them instead of giving into their friends. You have a big chunk of time to build them up with the lessons they need, but it can't be a one time conversation, and it can't just be the words you say. Your actions have to back up the things you're telling them. Otherwise, they will choose inevitably to do as you do, rather than doing as you say.
The second part is harder. It is knowing that you have said everything you can say, but your child now has to make a decision. You may have done and said everything right, and your child may still make a decision to follow the examples of friends, celebrities, etc. instead of listening to what he/she has been taught. This is part of life, and you should not beat yourself up if your child makes choices contrary to your teachings.
What you can do is make sure that your child can always come to you, whether his/her decisions are in line with your teaching/parenting. Even when they make dumb decisions, they need someone who has "been there" to give them input on what the options are, what the consequences are, and most of all to let them know that there is a way back (most of the time) if they screw up. This is not the same as condoning their behavior, but it requires that you not throw the mistakes in your child's face when he/she admits a mistake has been made (or hints around the possibility that maybe they didn't do the best thing in the world).