The answer kind of depends on how specific your knowledge about these processes is already, and of course you can narrow it down from these general points if you so choose. I will take as a given that you mean your question with reference to parts of the Spanish New World that were previously run as single entities, as presumably why those would remain apart from one another is not as curious. It is worth keeping in mind that Brazil was only one part of the Portuguese network of colonies, and it is only Brazil in that web we are addressing rather than the broad span of their holdings; as with Spain, the physical size of a colony only intermittently correlated with its value to the crown and how much it was prioritized. But as a starter:
-The process of independence of the Spanish holdings was anchored in the power vacuum created by the Napoleonic wars and the Babylonian captivity; where the Spanish monarchy was literally held captive in Spain by the French, the Portuguese king had his court evacuated to Brazil by the British. Thus, the period where New Spanish colonies had to find their own footing came abruptly and with no guidance from the previous chain of command. In contrast, Brazil actually fortified its bond to its once-absent ruler, who proved remarkably fond of the setting relative to Lisbon and somewhat reluctant to go back after Napoleon's defeat. As you can imagine, the return to power of the Spanish king not only meant his opposition to independence forces per se, but also exacerbated the factionalization within the Spanish colonies among elites who had conflicting goals (ie asserting primacy without a king was different from doing so once the king was back in power, and so on).
-The independence process for Brazil would not, as a result, come from a destabilizing vacuum, but rather a somewhat amicable separation between the king and his son who would take the throne in Brazil as a separate but linked state. Thus, there was a level of continuity between chains of command in the type of authority and the manner in which it was transferred that simply did not exist for the former Spanish holdings.
-Another important contrast comes in the means themselves by which independence was achieved, where you see a spectrum of processes and outcomes within the Spanish set. So the South American colonies went through multiple military campaigns after the restoration of the monarchy to power in order to try to quell the rebellions, which brought friction points between different leaders to bear relatively early and made clear that if there was a unifying tendency it would likely be gone if the Spanish threat ceased to be, not to mention the inherent destabilization of warfare itself. In regions less actively involved in the struggle for independence, such as the Central American portion of the Mexican colony, you see the fragmentation take place on a much longer timeline of decades of back and forth negotiations and smaller-scale conflict as the different centers of power within that group compete for authority in a post-Spanish era where independence has largely come from struggles external to their own relatively passive role (as compared to Mexican and South American involvement). Mexican unity itself is far from a foregone conclusion, with a great deal of intra-national conflict well through multiple incursions by foreign powers like the US and the French. At the extreme end of that sort of thing would be the Portuguese independence coming essentially at the stroke of a pen, more or less consensually on both sides as a pragmatic adaptation to changing circumstances for the weakened, impoverished European country.
From there, you could probably head into more specialized avenues like the degree to which the Portuguese-Brazilian process of education for elites through institutions like the university at Coimbra bred a more unified elite network than Spain's more meritocratic (in the negative and positive senses of the word) and less structured processes for people at the top of societal units. As a general rule, Spanish holdings are characterized as rigid and brittle where Portuguese exerted a lot less direct authority to begin with and had more flexibility as a result of the limitations of power present well before the 19th century.
I apologize in advance for the degree of generalization and any misleading implications that may result from painting with such a broad brush.