Where does it come from in a 401k plan? The obvious answer is "growth in asset values", but what does that mean? It means you took ownership of something that is worth more at the time of sale than at the time of purchase. That's an investment (aka "gambling") strategy and it MUST come with a disclaimer that returns are not guaranteed.
By contrast, socialized pension systems (of which SS is an example, albeit not a particular awesome one) are NOT investment strategies. Their goal is to provide a guaranteed income for people in retirement. It follows that they must be designed and work quite differently. One part of the strategy was termed "pay as you go", in which current workers pay for the outlays of current retirees. There's nothing inherently wrong with this approach, but as you note it can run into demographic bubbles. However, the idea that handling the one we are in/facing right now needs some sort of massive tax cut is false: just remove the cap on income subject to SS taxes, and there is no issue.
Corporate pension plans were/are a strange middle ground. Behind the scenes the fund manager would be following an investment strategy, but as far as the employee was concerned, the plan offers a guaranteed return. This was supposed to be able to work because the corporate pension plan offered a modest guaranteed return and behind the scenes, a more volatile but hopefully more substantial value was associated with the fund. This would, in theory, allow the company to make the payouts that formed part of the contracts it had agreed to with employees, but way too many companies failed to even manage that. And of course, it turned out that many had dipped into "their" pension funds to provide general corporate revenue or, even more brazenly, had simply not paid in the contributions they were contractually obliged to (I am not aware of a single company that has ever been sanctioned for this insanely illegal behavior).