How and why did the United States take a more active role in world affairs in the 19th century?
The US took a more active role simply because it was able to do so. Up to and for many years after the Secession or Civil War in the 1860's, the US foreign policy was defensive -- designed to keep other outside influences, mostly European, out of North and South America, as most of the country's energy was put forth in expanding west. However, after reunification and the settling of the West, the US began to expand its influence internationally and take a more vigorous, if not offensive role. The Spanish-American War of 1898 has proven to be the turning point from a defensive to offensive foreign policy -- By declaring war on Spain, the US sought to influence and perchance establish statehood in Cuba and the Philippines. In the first few years of the 20th century, the US influence in Central America paved the way for the Panama Canal, and its influence in Mexico brought about questions of Mexican autonomy.
The Monroe Doctrine was a statement of United States policy on the activities and rights of European powers in the western hemisphere. It was made by President James Monroe in his seventh annual address to the Congress on December 2, 1823; it eventually became one of the foundations of U.S. policy in Latin America. Monroe's statement initially remained only a declaration of policy; its increasing use and popularity elevated it to a principle, specifically termed the Monroe Doctrine after the mid-1840s.
The Monroe Doctrine was developed because the United States and Britain were concerned over the possibility of European colonial expansion in the Americas. Britain feared that Spain would attempt to reclaim its former colonies, which had recently gained independence.
The Monroe Doctrine was one of the first American foreign policy tenets justifying US Expansion.
Giving impetus to the Monroe Doctrine was the concept of Manifest Destiny--holding that territorial expansion of the United States is not only inevitable but divinely ordained. The phrase was first used by the American journalist and diplomat John Louis O'Sullivan, in an editorial supporting annexation of Texas, in the July-August 1845 edition of the United States Magazine and Democratic Review, a magazine that featured literature and nationalist opinion.
The phrase was later used by expansionists in all political parties to justify the acquisition of California, the Oregon Territory, and Alaska. By the end of the 19th century the doctrine was being applied to the proposed annexation of various islands in the Caribbean Sea and the Pacific Ocean.
So beginning with the Monroe Doctrine and coupling that with the belief in Manifest Destiny, the US considered itself almost solely responsible for protecting democracy anywhere in the world. This was a powerful force in developing a Navy and expanding with bases into the Philippines, Cuba, etc.