it is a way to fit in. The gang mentality is that everyone will take care of each other. Gangs are especially common in neighborhoods with children who have no father around them. It results from children who feel they have been abandoned by either one, or both parents, and so pursue a new family somewhere else, that they believe will not abandon them.
Not all teens, mind you, we are all individually different. Those that do like that have their own personal reasons. I have a family member who got involved with that because that was the only way to survive in that neighborhood (survival of the fittest, or smartest).