Reducing the number of illegal immigrants would reduce the net cost to state and federal governments, while reducing remittances from the US. That means that the cost of improved border security is effective paid by countries, such as Mexico, that send large number of illegal immigrants to the US even if there is no change to laws or treaties.
Consider a $5 billion improvement to border security. A reduction in the unlawful immigrant population by an average by 33000 households over 10 years would pay for the improvement.
For comparison there are about 12 million illegal immigrants in the US. Assuming 4 people per household (130,000 people) means that improved security needs to reduce the unlawful immigrant population by only about 1% to pay for itself. Illegal immigration to the United States - Wikipedia
The number of attempted illegal entries stopped by US immigration was about 500,000 last fiscal year; even a small improvement in enforcement would pay for increased security.
Remittances to Mexico and central America were about $50 billion last year. The total immigrant population from Mexico and Central America is about 15 million. A reduction in immigrant population by 130000 would reduce remittances by about $430 million/year. Over ten years the reduction in remittances is about equal to the cost of the improved security. Migrants' Remittances to Mexico, Central America Jump to $53 Billion
Therefore any outlay by the federal government could be more than offset by a reduction government expenditures to unlawful immigrants. Mexico and other foreign countries would effectively pay for improved border security in reduced remittances even if there is no change to US law or international treaties.
Mexican citizens in Mexico getting less money sent from illegal immigrants in the US, how does that equate to money being paid to the US Treasury by the Mexican government? It does not. That’s like saying my cup of coffee at Starbucks today was paid by you, because you found some loose change in your couch. I.e., it makes as much sense.