Spanish attempts to reconquer Mexico
Mexican independence was officially achieved on September 27, 1821, under the Treaty of Córdoba. Spain did not recognize the treaties, arguing that the viceroy Juan O'Donojú had no authority to recognize the independence of any overseas province. This situation was dangerous to the newly acquired independent status of the nation, which had not yet been recognized by any of the European powers that could support it, and the threat of Spanish reconquest was a constant worry to the leaders of the nascent regime. On May 13, 1822 decrees were issued by the government to imprison anyone who conspired against Mexico's independence.
Mexico–United States border
In the mid-16th century, after the discovery of silver, settlers from various countries and backgrounds began to arrive in the area. This period of sparse settlement included colonizers from different backgrounds. The area was part of New Spain, but due to the lack of population and the diverse citizenry it had, it did not seem to belong to any country. This period lasted until the early 19th century, at which point the United States bought the lands known as the Louisiana Purchase from France and began to expand steadily (militarily) westward in its pursuit of Manifest Destiny.
The border itself was not clearly defined and remained so until the Mexican colony became independent from Spain and entered a period of political instability. Mexico attempted to create a buffer zone at the border that would prevent possible invasion from the North. The Mexican government encouraged thousands of their own citizens to settle in the region that is now known as Texas and even offered inexpensive land to settlers from the United States in exchange for populating the area. The influx of people did not provide the defense that Mexico had hoped for and instead Texas declared its independence in 1836, which lasted until 1845 when the U.S. annexed it.