Let`s all be Brazil
Massive inequality. Racial/economic etc. Even besides the actual economic effects, this often creates a social culture of crime because many poor people feel that their situation is unfair. If you're in a poor country like, say, Bangladesh, where nearly everyone is poor and there isn't such a big 50/50 divide between rich and poor, its an entirely different mentality.
Lots of easily accessible guns. Gangs are bad everywhere, but when you put guns into the situation, they are able to exert a tremendous amount of power against both each other and their local communities. A guy comes to your store with a baseball bat demanding a monthly extortion rate? Okay bud, sure, get the ***** out. They come through a with a gun? You're gonna pay. It also makes it just generally easier to kill, obviously. Its less risky to take someone out.
Arguably the worst police in the world. Police in Rio kill nearly 200 civilians a month. It is absolute insanity with them, they are their own gang.
Drugs. This applies to all Latin america countries basically. Its why the region stands out so dramatically in terms of murder rates. And of course it applies to Brazil, and add in all of the other factors, it just adds up to an extremely high homicide rate.
But more than anything? Its cultural. Decades of extremely high crime rates have lead to many areas having a culture of crime. I've seen this in my own country (Russia, which used to the be homicide capital of the world) as well. Crime eventually becomes a vicious cycle, where the newer generations grow up in it and turn to crime because it becomes normalized in their culture.