Not until 1904 did the United States begin policing the border with Mexico.
Even then, the aim of the patrol was not to keep out Mexicans but to keep out Asians who were trying to enter through Mexico.
Because of anti-Asian sentiment, people from China and Japan were not allowed to make a home in the United States. Mexicans often came in search of temporary or permanent work, but were not counted as immigrants.
The idea that Mexicans could come “illegally” to a land that was once theirs is a relatively new one. Before it could become national policy, a few big changes had to happen.