Mimicking the behaviors of others is a natural part of development. Some children spend a period of time where they don't seem to do anything else.
Your son is trying out different behaviors as a way to understand his relationship with the world around him, which includes other people (other kids, teachers, parents, siblings, strangers).
One of the best pieces of parenting advice I ever heard was this (paraphrased):
"Children are the best researchers on the planet. They experiment with every type of behavior and every variation on that behavior. What are they researching? Cause and effect. Every time your kids misbehave or resist a boundary you've set, they are researching what happens when they do. That is, they are researching your reaction to their behavior. That is why it is vital that you be consistent in your discipline."
I've found this to be true with my kids. Often, when one misbehaves, the others will quiet down and watch carefully. Other times, they seem to research as a team the question, "How does dad handle multiple misbehaviors simultaneously?"
If your son is mimicking bad behavior, then calmly and consistently apply the consequences (time out, lock down, removal from the play arena, or whatever). Soon, your son will have learned this bit of cause and effect and go on to research another fascinating (translation: aggravating) aspect of his world. For a while...
then he'll come back to this question to see if a passage of time has changed the cause and effect relationship.
Welcome to parenthood!