It has crime just like any other place (e.g. a Phd in UCLA mapped gangs in LA, santa monica and Beverly hills had the most count of gangs and members) but the police treat favelas as their war ground, causing an artificial firepower escalation. And the reason is twofold: by twisting public opinion that favelas only have criminals you can relinquish all forms of state spending (culture, etc) and you can maintain a tight grip on the local political representation during elections, and favelas have lots of votes.
In sum, it has nothing to do with the gangs per-se. It's more artificial public policy.