So, as tenured faculty I don't know about NSF advocating for careers in STEM. Maybe that's a good thing maybe its a bad thing.

What I do see driving this ultimately is something broader and more systemic, which is universities being underfunded, administrator heavy, and being run as for-profit businesses.

In many ways, this all reduces to how grants are awarded and funded, and the history of grant funding.

Through the 80s and 90s, and to some extent early 2000s, federal grant funding increased. There was sort of a heydey in that time, depending on field, where there was good funding opportunities, in general, for faculty.

At the same time, state funding to universities started decreasing, and costs started increasing due to the higher ed bubble. Because of indirect costs on grants, which allow universities to charge the federal gov a blanket percentage of a grant, universities were able to skim off a profit almost automatically. It was a sort of win-win it seemed because faculty got to fund their research, unis got a cut to offset decreased funding.

The problems are many, though. First, federal funding went down after a peak, so this money pool dried up. Second, this system sort of led to the pyramid scheme you mention, where grad students get recruited to maintain grants and research programs with nowhere to go, lest universities and faculty lose indirect funding. Third, it prioritizes research based on grant receipts rather than utility, which distorts research priorities in a perverse way (especially given nepotism in grant culture, which has been written about extensively elsewhere). Finally, because of the history of all of this, you kind of end up with a system in which those running the system are either beneficiaries of the 90s and 2000s, and don't realize what it is like now, or came up through that system and have a kind of survivorship bias.

Agencies like NSF and NIH are basically just maintaining any semblance of research in the US at the moment, making up for all the deficiencies that are occurring at the state level.

There are problems with NSF and NIH, but they're not with advocating for STEM grads. They're with how grants are funded. Basically, review panels need to randomly rotate in some kind of jury pool system almost; grants need to be awarded based on some kind of lottery system (proposed by former heads of NIH); indirect cost charges need to be eliminated or made line-item justified; some grants need to be awarded on the basis of publication record without regard to a specific proposal (ala Hungary); universities need to be adequately funded outside of the grant system; and tenure needs to be protected (I say this as someone who is probably going to step down from my tenured position soon).

The problems facing grad students and postdocs are just the tip of the iceberg. They don't end, even when you get a tenure-track position, and even when you get tenure. The system is broken, it's a mess that favors hype and popularity over rigor. What you end up with is the current reproducibility crisis, academic fraud, people manipulating the system to overclaim credit, and many more problems that society is unaware of because they have a stereotyped idea of what happens in science--the sort of "great man in the lab with a eureka moment" which is a false model of scientific process.