In essence, a variety of socio-historical factors, but practically, I'll try to stick to the more recent history (i.e post 18th Century in practical terms), but in practical terms, Napoleon.
In 1808, the portugese court fled the Portugal as Napoleon's army invaded and occupied it. They established themselves in Rio de Janeiro (at the time the largest Port and most 'infuential' city in the then portugese colony). In 1815, Brazil was technically brought together into a United Kingdom along with Portugal and the Alvarges by Joao VI. In 1821, several years following the defeat of Napoleon, the king returned with his court to portugal, however, his son (Pedro) stayed as Brazil's regent. Pedro, a mere year after his father had left, declared his ambitions to control the territory, and instituted a constitutional Monarchy, with himself becoming the head of state Emperor Pedro I of Brazil. Following an indepedence war, in September of 1822 Brazil technically declared it's independence from Portugal.
Brazil, then, remained an unified constitutional Monarchy till 1899, when it was declared a republic following a military coup lead by Deodoro de Fonseca.
(I can go into why Brazil held together, but it's complex and I'm aware may not be totally answering your question).
Latin America's Spanish Colonies were, from the outset, characterised by a very different sort of rulership to that of Brazil, being Geographically significantly larger and more unweildy compared to the relative ease and contact of the Brazillian coast (note, whilst Portugal may have claimed to have administrative power over most of Brazil, in practical terms much of it's eastern and northern peripheries remained all-but unadministrated well into the 19th century). Whilst Portugese Brazil was practically only broken up into two states, the Estado do Maranhao e Para (to the north) and Estado do Brazil (to the south), Spain's American Territories were broken up into a far wider range of administrative zones, specifically, Nueva Espana (1519-1821), which constited of the Carribean Colonies, much of Meso-America and Mexico and northern Venezuela, La Viceroyalidad de Peru (1542-1824), which constituted much of current Peru and Chile, as well as other outlying regions, Nueva Granada (1717-1819), which constituted the territories which later became Gran Colombia, including Venezuela, Colombia, Ecuador, and parts of Guyana, as well as southern Meso-america, and Rio de la Plata, (1778-1814), maed up of Argentina, Bolivia Uraguay and Paraguay.
The revolution in Spanish America, for the most part, was led by Simon Bolivar (el Libertador), an enlightened revolutionary inspired by the US and Haitian Revolutions. When Napoleon invaded and occupied Spain, the colonies were left in Limbo (Bolivar wrote: ‘When the French eagles swept over the peninsula, crushing every fragile government until they were stopped at the walls of Cádiz, we were left orphaned" (Jamaica Letter p 21).
In a variety of struggles against Spain from 1807-1825, Bolivar, in his Jamaica Letter outlined his desire for a United Spanish America, however, in turn, for practical reasons (especially inspired by the work of authors such as Montesquieu), accepted a need to divide up the ex-spanish colonies he conquered into regions that could be governed more closely, as he wrote ‘… a state, too large of itself or together with its dependencies, ultimately falls into decay. Its free government becomes a tyranny’ p 9'.
The Jamaica letter is a must read and outlines these more closely, but lines include (‘The American states need the stewardship of paternalistic governments to cure the wounds and ravages of despotism and war. The metropolis, for example, would be Mexico, which is the only country capable of assuming that role, because of her intrinsic power, without which there can be no metropolis’ p 24, ‘Perú … contains two factors that clash with every just and liberal principle: gold and slaves. The former corrupts everything; the latter are themselves corrupt. The soul of a serf can seldom really appreciate true freedom. Either he loses his head in uprisings or his self-respect in chains’ p 10).
He ultimately consolidated the independence of these territories in 1825, into the nations he felt would best allow for their political stability, those being Mexico, the republic of Gran Colombia which later broke down into New Granada, Venezuela and Ecuador), Peru, Bolivia, Chile, Argentina, Paraguay and Uraguay.
If you want more on Bolivar's exploits and the exact politics of the post-independence states, please ask and I'll more than happily proivde.
In essence, closing remarks to answer your question: Brazil became a monarchy under a Portugese Prince, the Spanish Colonies were divided up by an Enlightened Republican due to their demographic and political challenges.
If you've any other questions queries or interest in the politics of the transition, please don't hesitate to contact me, I've areas of expertise particularly on Bolivar himself and Enlightenment Political Theory more generally and have missed a large amount of this out as to try and answer your question more aptly.
Sources:
Sorry, there's probably loads left out from here, I'm a Hispanic Studies Scholar at heart and I don't have all my critics down straight up! - Please ask me to find me reading list and I will find it!
Bolivar, Simon (1815), 'Carta de Jamaica', Kingston, Jamaica: [Accessed 17/09/2018] https://library.brown.edu/create/modernlatinamerica/chapters/chapter-2-the-colonial-foundations/primary-documents-with-accompanying-discussion-questions/document-2-simon-bolivar-letter-from-jamaica-september-6-1815/Andrien, Kenneth J. and Lyman, L. Johnson. (1994) The Political Economy of Spanish America in the Age of Revolution, 1750–1850. Albuquerque, University of New Mexico Press
Burns, Bradford E. (1980) The Poverty of Progress: Latin America in the Nineteenth Century. Berkeley, University of California Press,
Humphreys, R. A. and Lynch, John (1965). The Origins of the Latin American Revolutions, 1808–1826. New York, Alfred A. Knopf,
Swanson, Phil (2014) The Companion to Latin American Studies, Routledge
Britannica (--) History of Brazil, Encyclopaedia Britannica [Accessed 17/09/2018] https://www.britannica.com/topic/history-of-Brazil
Pimenta, Joao Paulo (2014) BRAZIL AND THE WORLD REVOLUTIONS AT THE BEGINNING OF THE 19TH CENTURY, JHIBlOG/Princeton [Accessed 17/09/2018] https://jhiblog.org/2018/03/21/brazil-and-the-world-revolutions-at-the-beginning-of-the-19th-century/