When Mexico first became an independent republic in the 1820s, the US and its trade was not dramatically affected. However, over the years, a great impact was felt.
When Mexico gained independence, the US was still not an economic giant. Because of this, most of the trade with Mexico and investment in Mexico was done by the big European countries.
As the US became stronger economically, it came to have much more of a trade relationship with Mexico. This really became very big during the Porfiriato as huge amounts of direct investment by American companies flowed into Mexico.
So an independent Mexico eventually became a major source of raw materials for the United States (as well as the "cause" of a war in which we took much of their former national territory).