Norman Matloff of UC Davis has amply documented how companies have been abusing H1-B for years to lower salaries, with the side effect of discouraging native workers ("internal brain drain"). And he has repeatedly refuted the bogus shortage shouting of technical workers, particularly in computer science.
The Fortune 500 company I work for uses huge numbers of H1-Bs, while I saw many tech coworkers laid off from a previous company struggle to find work, even at lower pay. Well before H1-Bs became prevalent, the tech job market was simply too competitive, and wages too pitiful, for there to have ever been the kind of talent shortages claimed, at least outside silicon valley.
Just follow the money. Stagnant wages tells the story. To CEOs, engineers are equal replaceable units, just need to find the cheapest ones.
As I was being processed in a downsizing from a company known for High Priced equipment, I found an H1-B visa justification form someone had inadvertely left in a copy machine for the same job I had been doing. They catagoirized the job in a way where they could justify lower prevailaing wage, something like 30% lower if I remember correctly, but the job description was the same. This was about a year after our manager told our group that we had to summarize how we designed and debugged designs and transfer that knowlegde to our "co-workers" in India. Uh, yeah, I'll get right on that ....
Your experience provides a good argument for why we should not be exhorting more students to persue STEM careers in those cases for which they have no great passion for science and engineering. Many students are already choosing careers with a more stable employment outlook and less stagnant wage appreciation (such as pharmacy, physical therapy, law, medicine etc).
That U.S. schools may have too much of a theoretical bent in the education of American CS students may derive from computer science being inappropriately identified with those engineering disciplines which are more related to the physical sciences. A more vocational track for CS students might be more productive than the system which we have.
And yet, the observation that there is no STEM worker shortage remains valid given the labor statistics. The fact that individuals who are trained for other professions than those in which they are eventually employed is not peculiar to engineering professions nor does it mean that they are either employed or satisfied that they couldn't find a job in their chosen profession.
That facts are conclusive that there is no STEM worker shortage and the reason is not a dearth of STEM graduates.
Randy Bullock received his degree in Petroleum Engineering from Texas A&M and is now the kicker for the Houston Texans. So he counts as part of that 50% of STEM graduates who did not take a "STEM job". Should we feel bad for him? Ryan Tannehill received his BS in Biology from Texas A&M and is the quarterback for the Miami Dolphins. We have got to do something about all these STEM graduates going to the NFL!
The primary reason half of STEM graduates take non-STEM jobs is because companies want to hire STEM graduates for all sorts of jobs, including non-STEM jobs, because they are smart, can think analytically, etc. Engineering graduates who aren't great placekickers tend to take engineering jobs, but many science and math students take jobs outside science and math. I've met many such former students who are doing very well.
As was alluded to, another thing to consider is the distribution of graduates and their skills. The bottom 10% may not be the best choice for a STEM job, but may do just great in another job. Since this is EE Times, and Texas now offers a Professional Engineer license in Software Engineering, perhaps an interesting discussion would be the PE license as a way to better identify competency. It is standard in fields such as Civil Engineering.