At the undergraduate level, there's no "problem," as none of the US government-backed or university-backed financial aid programs support nonresident foreign nationals. Our universities take their tuition money and provide an education.
The issue would be at the graduate level in the sciences and in engineering. But we need to be extremely careful about exactly what is being paid for. First set aside fellowships, which also don't apply to nonresident foreign nationals. The absolute standard practice is that Ph.D.-level graduate students in the sciences and engineering have their tuition, and a small living stipend, paid for by a combination of teaching assistantships and research assistantships.
In the case of teaching assistantships, then the grad student provides some number of hours per week of teaching, and in return gets his or her tuition paid for and a modest stipend. This is in turn funded by the tuition that undergraduates pay. The University is, in essence, simply hiring someone to do a job. The grad student spends some of his or her time teaching and uses the rest of his or her time, and status as a University student, to further his or her own education. Although there can be issues with non-native-English-speaking foreign graduate students and their ability to communicate in English, that is beside the point, and there's no investment in the grad student, on the part of the government or the University, that's being "lost" if the grad student returns to his or her home country after graduation.
In the case of research assistantships, these are offered by individual faculty members to graduate students working in those faculty's research groups. The faculty, in turn, get the money from research grants, almost all of which are funded by the government. However, the funding agencies are not directly funding specific students, rather, they are funding particular projects. To get a research grant, the faculty member submits a grant proposal that details what they expect to learn, and how much it will cost in terms of equipment, materials, labor, and so forth. When such research leads to interesting results, it is published, and the funding agencies are acknowledged. What funding agencies want to do is fund successful work. In this case, the funding agency is paying to have a particular scientific question investigated. Invariably, the people who are actually in the lab doing the labor to produce the results are either the grad students, or postdocs, or sometimes undergraduates. Their salaries, and grad student tuition, are paid in exchange for this labor. But fundamentally, the government funding agency pays for, and hopefully gets, scientific results, without concern for who does the work to get the results. But again, there's no investment that's being "lost" if the grad students or postdocs who did the work decide to leave the US once the work is done, because the investment was in the scientific work, not the individual students.
With the graduate population in the sciences and engineering at US Universities, you'll find the whole cross-section of American graduate students, plus the very best of the foreign graduate students. Only the cream of the foreign crop comes to the US, and this leads to the skewing of the graduate populations in which the best and most promising students are more likely to be foreign. And for the faculty researchers, its in their best interests to work with the best students, in order that their work be successful and lead to further research grants. So it can be in the best interests of faculty, and the Universities themselves, to welcome the best foreign grad students into their research groups.