STEM = science technology engineering math
CS/software has huge demand and salaries to go with it (yay, ads)
Traditional (civil/mech/ee/chem/etc) engineering is OK. You'll never be rich but you'll always be comfortable. (I've had plumbers claim theye make more than me).
Science and math have really bleak career outlooks. Tenure track faculty jobs are a crapshoot. Industry jobs are scarce. Most people I know from college that went into the sciences are either still stuck in PhD or postdocs, or quit after BS/MS and now working as lab technicians or equivalent. Not even glorified, just plain old overqualified lab techs in QC departments and such.
Edit: As a final note, here's a 2015 report from OSPE, an organization representing engineering professionals in Ontario, Canada: https://www.ospe.on.ca/public/documents/advocacy/2015-crisis... An except:
"Information referred to in this report is derived from the Canadian National Census 2011 National Household Survey (NHS). According to the 2011 NHS1, only about 30 per cent of employed individuals in Ontario who held a bachelor’s degree or higher in engineering were working as engineers or engineering managers. Fully two-thirds of engineering-degree holders were not working in engineering at all. Many had jobs that didn’t necessarily require a university degree."
Plumbing is an essential service, and in emergencies, hourly rates can go into $300+/hour. So why don't everyone go into plumbing? Cause it's a shit job (/s)
Jokes aside, my take on the science job contradiction is that current American society does not respect nor want the products of science.
Think vaccines - when we have an emergency, everyone wants one, but in "normal times", think about where the pockets of the anti-vaccination movement have taken hold: rich communities in California where science should have had the best chance of surviving, but is struggling.
Communities in the American Southern states who are having trouble keeping evolution and science curriculums in tact are another example.
The solutions to the "STEM shortage" are usually to ramp up training (BS/MS/PhD students, occasionally postdocs), without actually creating viable jobs for these folks when they finish. Many smart people don't want to get involved in a cutthroat job market, so either leave the field or never enter it. (The people who "left" science from my grad school cohort were all very smart; almost all of them could have cut it)
Meanwhile, cutting-edge research is mostly done by trainees who are learning as they go. This is important--we need future scientists as well as current ones--but it limits the projects and pace of research.
This is totally fixable too--fund more staff scientist positions and dial down the number of trainees. The NIH funds thousands of studentships and just a few (~50?) "research specialists."
As for why people work at those salaries, there's more to life than money. Discovering stuff is fun and working on stuff that really helps people (not in the "expensive subscription juice service" sort of way) is rewarding. People teach for the same reason.
OTOH, taking a job at these wages is a luxury and chases good people out of the field. My spouse and I are both academic research scientists, but anything happens to one of us, the other's out ASAP.