I am not brazilian but I know the country quite well since Brazil is like my second home. I have tons of friends I know from there and I am there several times a year.
Brazil is bordering several countries that: are unstable, very poor, have high crime rates, produce and traffick drugs and guns, have jungle militias, illegal immigrants, the borders are inexistent and practically have no monitoring, which makes drug and gun traffick easy for criminals. That's why you see criminals with very powerful guns and even .50 cal rifles and machine guns. Also, it has a port that is the closest (in the continent) to africa and europe, attracting international drug traffick. Added to that, the northeastern region is very poor and has almost no natural resources and no good ways to make money. Brazil is also SUPER easy to emigrate to, which attracts people like africans as Brazil has a large black culture, specially in the northeast. Many africans go to Brazil and survive with crime, many Nigerians.
It is very hard to manage a country with big population. It is hard to make vast amounts of people to agree on ideas and elect the good politicians. Countries tend to be divided given huge populations. Brazil has 210 million people. That's a fucking MASSIVE population. Given what happened in the history of Brazil you will see why the country is so divided and how the population amount makes a huge difference. The population of Brazil is very, very, very diverse. Many people, despite of the huge problems, are very attracterd to Brazil and many of them move there. For example, there are a lot of scandinavians in the northeast, TONS of germans in the south and more diverse europeans like italians, french, japanese, chinese immigrants in the southeast. Due to their origins and the history they had in the country, they will always differ a lot in political and social opinions. Let's also mention that Brazil has a fucking stupidly retarded number of political parties, which just adds up the divide and confusion.
Brazil is a ridiculously big country. It is the size of a continent and europe (except for Russia) would fit in Brazil 2 times over! Meaning it has a lot of territory to monitor and manage. It stretches from moderately cold to semi-arid climate. It goes from the 33th parallel south all the way up to the 5th parallel north, above the Equator. That's just how fucking gigantic Brazil is.
Most of the population lives near the coast, around 80% of the country, leaving other areas a bit isolated with average cities and towns. Given the remote location they are in, it is hard to manage operations and attract investments and generate jobs. Brazil borders 10 countries, that's all countries in the continent except for Ecuador and Chile. The border is 16,885 kms long. That is ridiculous. You just can't monitor and control all that, including very, very remote places all the time to stop criminal activities. Leaving the country severely in danger.
The distances between important cities are very big and building roads is a pain the ass considering the topography of the country. You can drive like 1,500km and still be in the same state as they are just so huge.
Managing such gigantic land is an absurd task. That gives you lots of municipalities, which makes the country have a loooot of politicians and consequently, more chances of corruption.
Having less things to monitore and manage is obviously easier than a country the size of Brazil.
Being a small country bordering other small countries gives you less borders to take care of. Being small, having low population and having a good location make it faaaaaaaaaaar easier for a country to be developed and well administered.
That's what I can explain.