Isn't the trust fund a fake concept? Benefits are always going to be paid from current year tax or borrowing. You can't actually "invest" trillions for the future if you're a government. At least that's what my Economist mother told me.
Country A ensures they don't run deficits and pay off their debts to prepare.
Country B prepares by incurring a debt to build hospitals and train nurses.
20 years later the demographic crisis hits. Country A cannot build hospitals and train nurses fast enough to meet the need so the price of both skyrocket and the piles of money they "saved" is inflating away to almost nothing.
Meanwhile country B is fine.
The costs Country A incurs are plowed back into Country A's economy during the "building boom".
Don't know which country ends up better off, but there are many more variables than you imply.