You're the richest nation on earth.
You can afford it, the people who control the purse strings choose to use it on other shit that benefits themselves.
Well, we also seem really bad at managing education. There has been a huge increase in the number of non-teaching staff (i.e. administration) in schools. At the same time that we wring our hands over class sizes, a growing proportion on dollars spent ostensibly on education go to stuff that doesn't happen in the classroom. We can "barely afford" stuff when we let a whole industry of nonessential stuff graft itself onto the thing we actually care about.
How else does one track “richest” anything? On paper is what matters when counting wealth.
That said, the gap between capability and actuality of spending that your parent comment is lamenting is the gap for that on-paper wealth not being used for real-world-improving actions, and instead being used to increase the on-paper wealth of a tiny minority of wealth-holders.
Humor me, by what measure is the US the richest nation on earth, or even close? Anything per capita will be dominated by Monaco/other tax havens. Anything on a gross level will be dominated by China.
Add in underfunded liabilities and lets see what it shows us. Of course if a country doesn't require all liabilities to be counted it's going to show up at the top of the list.