Why do teenage boys act so immature around each other?

OK so I know boys mature slower than girls but how come they feel the need to act immature and perverted around other guys but when their with a bunch of girls they are really nice and mature. It's almost like they have a personality switch when hanging out with guys as apposed to girls. I have my ideas such as they feel the need to prove themselves to other males or they are nice to girls because they want something from them and their being nice is all an act.

Also I have a very good guy friend who acts mature around both guys and girls and they call him a whipped tool, why do they feel the need to tear him down?
Why do teenage boys act so immature around each other?
Post Opinion