Similarly, not everyone can become a project manager, product manager, head of engineering, or whatever.
So as you age, you can take one of those career changes, or just ... find a long-term niche and stick there or keep up with what's new, and sell your experience.
There is a world beyond single 25 year-olds working stupid hours in startups.
I don't known what it means "older devs have it harder". I am a valued contributor, and if something bad would happen I have a pocket full of leads where to find next gig.
You have to maintain your career - nobody is going to do that for you. So yes, you have to figure out how to become a valued contributor.
Make sure your CV communicates you are "smart and gets things done" and you are set, more or less.
Perhaps software engineering is a bit more fragile than other more professional fields as there are lot of young uneducated employees who can be abused and exploited by unscrupulous employers. But generally you learn to identify those, and with a good CV of years of successful projects, you can find agreeable employment in most market situations.
There’s nothing wrong with this.