As opposed to a single colonial identity? Obviously asking about the former colonies of Spain since Brazil is one unified colony rather than several portuguese speaking ones. Why did they feel disctinct from each other if they spoke one language and followed the same religion? At which point did they start to think of themselves as Mexican, Colombian, Peruvian, etc. rather than subjects of spanish crown?
This is the central question of modern Latin American history really (And for the record I think your question also applies to the United States, to Brazil, and really to all of the other nations of the Americas). Where did a sense of national identity come from? The simple answer is that no collective identity ever existed in the colonial period. The resulting national identities we see today were actively constructed over the last two hundred years in a process which is still incomplete.
For those who have studied this history, you will find my answer to be quite shallow and general. Feel free to add whatever you like to it.
During the colonial period, the Spanish Empire was enormous and diverse. The American continent is over 16 million square miles and features climates ranging from tropical rainforests, to temperate climates, to highland and alpine climates. Enormous mountain ranges, extensive systems of rivers, and dense forests limited communication and transportation while shaping the trajectories of colonial enterprises. European immigration was small; in fact, far more Africans crossed the Atlantic before 1810 than did Europeans. Despite a so-called “conquest,” indigenous peoples were never completely incorporated into the empire and had only limited contact with outside cultures. Early modern systems of government gave local officials widespread autonomy to make decisions on their own, and individuals easily ignored laws. While some social class and cultural affinities bound people together, the thing that held the Spanish Empire together most effectively was the King himself. When the King was out of the way, people set about trying to come up with new systems to replace him that were more in their interests.
It took most Latin American nations decades to establish national governments and define national borders. This process included the attempted construction of larger collective entities like the Mexican Empire, the United Provinces of Central America, and Gran Colombia (among others), which collapsed quickly (you can look up some of these in the AH’s FAQ under political fragmentation). Smaller regional or “national” governments also collapsed because of infighting among elite groups who had competing interests. Consequently, completely new nations ended up on the map (like Uruguay for example). The process of nation formation sparked significant armed conflicts both internally and externally (new nations occasionally fought over who was in control of neighboring nations or where one nation ended and another began).
In the post-indepence world, a major challenge was deciding what to do with all the indigenous people, free blacks, and slaves that made up the vast majority of the population but who were also thought of as lesser beings. As you might expect, each nation in the Americas dealt with this question in their own ways. Some tried to maintain forced labor structures (Brazil for example kept slaves longer than any other nation in the Americas [but not by much]); others made significant reforms. Over the course of independence in Spanish America for example, many indigenous people and slaves were promised freedom in one form or another. As a result, many Latin American nations were at the forefront of abolishing slavery and offering citizenship, yet when the civil wars ended, what did citizenship look like for these indigenous people and free blacks? Unfortunately, many of the elites who came to power failed to translate freedom into full fledged participation in the new nations. Governments used laws to form “orderly” societies, which basically equated to the reinstatement of slavery or indigenous labor systems. For example, Brazil used all sorts of anti-vagrancy laws after abolition to force newly freed blacks back to work on plantations.
New nations also had all sorts of leftover colonial baggage. For example, many indigenous communities owned land collectively, which elite reformers often viewed as unproductive. They believed that private ownership was more productive, so they attempted to “reform” the land holdings by confiscating it or selling it. In other cases, poor families were gradually forced off their land or bought out by wealthy landowners or foreign corporations (Cuba for example).
As the wars of independence and nation formation subsided, nation-builders tried to establish institutions that could create informed citizens capable of participating in democracy. This included opening public schools that could instruct people on what it meant to be a part of the nation, as well as provide basic skills that could be used to improve the economy. They also opened things like science museums, which might showcase the natural history of the territory or its unique plants and animals. Or they might open art museums, which taught the citizenry how to be “civilized.” This period also saw the government become more invested in developing agriculture, industry, and infrastructure (considered to be the markers of progress and modernity). Many of these projects came to be dominated by foreign companies, which in turn developed questionable relationships with men in power, leading to interventions by foreign powers when new governments moved against the interests of their foreign investors.
Some countries in the Americas experienced significant immigration and urbanization. Often, people in power hoped that immigrants would be white and from “industrious” nations like Germany or England. More often, millions of people from Southern and Eastern Europe poured in, further expanding the diversity of an already diverse place. These immigrants and many of the poorer, darker-skinned people who had been forced off their land ended up living in squalid neighborhoods in cities. As the decades wore on, governments came to offer various social services and provide labor reforms to help these people, which caused more people (both locals and immigrants alike) be more invested in the state. These investments also paid for city infrastructure, public transportation, parks, and public health campaigns, which improved the lives of some citizens. However, these reforms were sometimes too little too late. Places where the government failed to take big steps at reform saw coups and uprisings, the most famous of which is the Mexican Revolution, a watershed moment for Mexican national identity.
In this late nineteenth/early twentieth century transition period, I see the formation of intellectual imagination formulating national identity. People like Sarmiento, Ortiz, Martí, Freire, and Vasconcelos (to name just a few) pondered what it meant to be Argentine, Cuban, Brazilian, or Mexican. They penned texts that tried to make sense of the complexities of their territories. Sarmiento famously identified Argentines as a mixture of civilization (Europeans, urban white people) and barbarism (gauchos and indigenous people from the frontier). Vasconcelos defined Mexicans as a mix of indigenous people and Europeans. Intellectuals wrote national histories that explained what specifically made them different. For instance, Freire explained how the Portuguese and African roots of Brazil gave the nation its distinctive character. They also described national identities in terms of what it was NOT...that often time was the United States. As the US exerted increasing hegemony over Latin America, many became disillusioned, especially when they personally traveled to the US and experienced its shocking, hypocritical racism. However, national identity might also be formed closer to home. For instance, Dominican identity was shaped by the fact that they were NOT Haitians.
At the same moment, one also sees the construction of an artistic imaginary that often closely paralleled these intellectual and institutional construction projects. For instance, many of the most famous Mexican artists show post-Revolutionary Mexico as mixtures of indigenous and European descendants in their murals. These were painted in government buildings where they could be appreciated by the public. Composers like Carlos Chávez blended classical European musical forms with indigenous musical instruments and/or popular melodies. His orchestra gave many concerts for free, so even the poorest person in a sense could hear their national identity. Even the creation of national cuisines helped create distinct identities. The taco for example came to be associated with Mexican identity only in the early and mid-twentieth century.
All of these constructions have been haphazard. There are ongoing border disputes left over from the relatively improvisational creation of borders. Foreign ownership, land disputes, poverty, and foreign interventions are frequent sources of conflict throughout the twentieth century. Not everyone identifies with their respective national identities. Many indigenous peoples still identify with their indigenous group, speak indigenous languages, and receive virtually no services from the state. Others have written out of these broad national identities completely. Despite receiving massive numbers of African slaves, the national identities of countries like Mexico, Guatemala, Argentina, Uruguay, and Peru (just to name a few) have intentionally erased blackness from their collective memories. Perhaps all of this is why the term “imagined communities” has had such staying power: nations are sorta made up.