Prior to 1848, most of the Southwest was part of Mexico.
Prior to 1875, the United States has no laws restricting immigration of any kind. While selected exclusions for convicts, prostitutes and immigrants from China were enacted over time, there was not a comprehensive law limiting immigration to the United States until 1924. There was no effort to control the U.S. land border until 1891.
Migration between Puerto Rico and the mainland United States has been completely unrestricted since 1917 when Puerto Ricans were granted United States citizenship.
The 1924 law, which was in effect, with various amendments until 1952, dramatically limited immigration to levels that remain the lowest in U.S. history (also influenced by the Great Depression and World War II which both discouraged immigration). Immigrants from Latin American and Canada, however, were not subject to the quota systems of the 1924 Act, even though large waves of Latin American and Asian immigration largely dates to the period after the mid-1960s.
In 1952 quotas were established based on national origin, with certain exceptions.
In 1965 something approximating the current system was put in place, although it was extensively amended in 1990.
In short, immigration laws limiting Latin American immigration to the United States are a relatively recent phenomena.