A big part of the problem is that our STEM grads aren't allowed to rise to the occasion. Yes, they might not have literally every box checked off. But they made it through engineering, one of the most rigorous undergraduate programs offered by the nation's universities. That should count for something. A new STEM graduate really doesn't have much of a direction in their career until someone comes along and gives them a chance and an area of focus. A significant majority of EE skills are highly transferrable, but try explaining that to some HR clerk who basically knows nothing about engineering and is merely trying to match keywords.
Everyone has to start somewhere. And many of the H-1B's are entry-level workers and/or lie about it. Or they actually got that 'entry-level' experience by being on OPT, essentially an unpaid internship, for 2 years. While domestic grads are left to rot and aren't even offered meaningful internships. I know, as a 2002 graduate of Electrical Engineering and Computer Science, top quartile of my class, who has submitted thousands of resumes to companies claiming to be hiring, the whole process has been humuliating and it is clear that firms are not trying to hire domestic talent in good faith.
A huge number of engineering grads can't get hired at any cost. If they apply to low-end jobs, they're rejected as 'overqualified'. If they apply to high-end jobs, well, the firms want 5+ years of "experience", and throw arbitrary coding tests and all sorts of other unprofessional screening criteria. Not to mention H-1B competition. Yes, engineering might have a higher "starting" salary, but it lags behind severely as time goes on compared to the salary progression in other careers. That is, if you can actually find that first job -- the stats are pretty dismal. And rejected engineers face a lot of problems finding employment outside the field as they are viewed as a 'flight risk' from non-engineering jobs.
Silicon Valley tech shortages never really existed. An often cited example of 'shortages' was in the late 1990s when a new Masters graduate was paid $100k to start and was offered the lease on a Porsche. In probably one of the hottest fields at the time, design of communications ICs.
$100k might seem like a lot to a cud farmer in Alabama, but in the Bay Area, even at the time, it didn't really qualify someone to get into home ownership. It wasn't even equivalent to the compensation paid to a lawyer, dentist or a doctor after a few years on the job. Even today, with the apparently 'hot' tech market, we have police officers in the San Jose solidly out-earning all but the most elite of Silicon Valley tech workers. Yes, mere police officers. And even the $100-$150k on offer for the elite programmers doesn't even scratch the surface of the sort of income required for basic entry-level home ownership.
Actually in my experience, it was the bottom half of the class that got hired. Not the top half. The bottom half had much lower salary expectations, and would accept being hired for low-wage 'grunt' sorts of positions. They also tended to aim at the electric power industry and residential/commercial electrical engineering consulting, rather than the higher-end industries of electronics, digital systems, communications, etc. The more traditional industries have performed considerably better for EE's than the newer, higher-end areas, hence, the bottom half of the class is mostly gainfully employed while the top half struggle to even maintain a foothold in the market. This is after over a decade since graduation.
GPA was rarely a determinent of hiring, but rather, tended to correlate to the sort of areas that people gravitated to. Most of the 'math' used by the employed people tends to be basic 2nd -year EE phasor arithmetic and 3phase stuff, with a bit of motor theory and PLC programming thrown into the mix. The H-1B's have decimated the higher-end EE areas, to the point where the top grad in my graduating class took years to find a job (albeit in the Silicon Valley), and was actually recently laid off in a sweeping reorganization. Brilliant embedded systems engineer he is, summarily discarded.
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.