We take in foreigners to do STEM (consequently putting significant downward pressure on STEM compensation), so our people can do service jobs that aren't as cognitively demanding but paying just as well or better. Who wants to do sciences/engineering for four years and on top do 4-7 years for PhD and postdoc? There's a reason why kids of the more affluent are less likely to do engineering/science.
I completely disagree with your assessment that foreign students put downward pressure on STEM salaries. In fact, I'd argue the opposite: they increase STEM salaries because they create more competitive companies which means more STEM jobs.
The foreigners that do come here to study are usually the brightest in their respective countries. And most of them want to work and do work for American companies afterward, helping them become more competitive companies globally.
And the U.S. has historically had a giant shortage in stem talent. I work in Silicon Valley. I'm in at the director level and I hire software engineers. Without foreign students and skilled foreign workers, Silicon Valley is screwed. I estimate that roughly 50% of the qualified candidates we interview are either skilled immigrants or previously foreign students. The foreign talent literally keeps Apple, Google, Amazon, Microsoft, and most Silicon Valley companies competitive globally.
And not only do these foreign students help make American companies competitive, but their future kids also do as well.
Elon Musk was a foreign student. How many STEM jobs has Elon taken away from Americans? Zero. How many more STEM jobs have Elon's companies created directly and indirectly?
Sundar Pichai was a foreign student.
And while Lisa Su and Jansen Huang were not foreign students, they're both immigrants.
Just a few examples.