Actually it is a communism vs capitalism thing. The problem arises in both, but the solutions available depend on the system. I reccomend you look up how China is handling its massive elderly population. For example the elderly there have huge public parks and get outside moving and socializing a lot. In big cities it's common for them to have mid day slow dance meetings in the parks. This is only possible because the government's priority is not producing profit for billionaires but caring for its people. So it maintains these things and the public transport required to get the elderly there, and the assistance to keep them fed and healthy.
This video is 15 years old: https://youtu.be/SvmV7GRRPq0
When people stay active and a part of their community into their old age instead of sitting in their huge houses alone or in a nursing home they require much less support to keep living.