Right from birth children learn by observation and imitation. Your infant learns facial expressions from you. Your baby learns words from you. Your toddler however learns from everyone. In fact new research shows toddlers as young as 14 months can even learn and remember actions and behaviors seen on television. So it comes as no surprise that toddlers also often pick up bad behaviors and habits from other children or adults. As a parent this can present a catch-22. On one hand you want your child to be well socialized and interact well with other people and children, but on the other hand bad learned behaviors can be extremely frustrating especially with a toddler already in the "terrible" stage. So what can you do to prevent your toddler from learning picking up bad behavior from others?
Remaining consistent in the face of bad behavior
The most important thing you can do as a parent is be consistent. Even if the negative influence you are dealing with is present and his/her parents, address bad behavior immediately. Don't feel as if addressing your own child's behavior may single out, embarrass or offend the other child's parents. Different parents have different rules and approaches, one way may not be right for everyone. For example I let my toddler son color on our walls with washable markers. It comes off easily and he enjoys it. Most parents would view wall coloring as a negative behavior, but I do not. No matter where you are and whose around you need to stick to the rules and discipline forms you have established. If the negative behavior is a new habit, you also need to act quickly so that your child doesn't think this behavior is okay.
In the case the negative influence is an adult you should not only address your child, but the adult. In the case of a child you may want to avoid doing so, so as not to over step your bounds into another parent's realm, but an adult should know better. Be frank, honest and polite. Simply say, "Hey, I'd rather you not do *this* around my child please." In most cases people are willing to oblige your request.
You may also consider asking a parent to address an extremely bad or possibly dangerous behavior in their child that your child is copycatting. Again, be polite, honest and in this case tactful. Avoid accusing or suggesting bad parenting. In example, say your toddler's new role model likes to climb the entertainment center in the living room. Perhaps say to his/her parents, "That entertainment center doesn't look very sturdy. He/she could get hurt. Do you want me to get him/her down?" This brings their attention to the fact that the behavior is dangerous even if it doesn't point out furniture climbing is simply a bad thing for a kid to be doing which should result in them stopping the behavior.
Limiting negative influences
In the event a behavior is dangerous or extreme and the parents or the adult are unwilling to address or change the behavior you may have to debate limiting or eliminating your child's contact with this person or child. The same way you wouldn't let your toddler watch a television show that taught him or her a bad habit just because he/she enjoyed it, you shouldn't continue to expose your child to a negative influence just for the sake of friendship. There are many toddlers out there to set up play dates with, social interaction can be obtained from other sources.
Outside of remaining consistent, being quick to react and correct negative behavior, and limiting or even eliminating negative influences there's little more you can do to prevent your toddler from picking up behaviors from other kids or adults. On the upside your toddler will likely also pick up positive habits and behaviors.