I think you'll come to realize that it isn't your attention span but rather the amount of mental energy you have left after working a 9 to 5 for 5 days a week
Bruh, I'm 33 and I started playing Subnautica for the first time a few weeks ago only to realize that in the first day I accidentally played for 10 hours. You just need to find the right game for you to revitalize your interest in gaming. Whatever that game may be!
For me, the attention span isn't the problem. I have been going on DOS2 and Factorio benders over the last couple years. For me, it's about making sure that I don't have some niggling anxiety in the back of my mind ruining my concentration. Got chores done? Dinner prepped? Laundry done? Animals fed? Game time baybee.
You just gotta find the right game. I discovered Satisfactory last year and had to uninstall it after a few eeks because I was staying up till 2am playing. I am 40.
This is how I felt until I played Valheim and BG3. I think my preferred genres have just shifted. I need something I can relax and play at my own pace. I use to only play competitive shooters, where I needed to be "on" the whole game. Now I can only play a shooter for about an hour before my mind starts to drift and I lose interest.
I've put over 400 hours into vanilla terraria and recently started the calamity mod, first day I put like 6 hours into it.
I don't play every day, I just don't have the time/energy. But when I do I try to make it count.
That being said, we used to play Edward forty hands and try to beat ocarina of time in a single evening, usually staying up until dawn despite the copious alcohol.
I'm not the stallion I used to be, but even an old horse has something to prove.
If your only issue is that modern games suck, rather than A) Being too exhausted after work, B) Having social media-induced attention deficit, C) Being overwhelmed with other responsibilities or anxiety, or D) Simply just not having enough time, you just have to find games that are actually good. Not AAA grindfests that aim at keeping you glued to the screen getting collectibles for 80 hours, but games that are actually trying to provide you with a worthwhile experience.
Some suggestions: Subnautica, Outer Wilds (not The Outer Worlds), Disco Elysium, Pathologic 2 (mind you, this one is extremely stressful, it's a masterpiece but most people will not enjoy it), The Forgotten City, Hades and Omori.
Trying to learn how to play a Final Fantasy game in your late thirties is like trying to learn brain surgery on a worm. I don't know how I had the patience for any of that shit back in the day.
There's a bit of a hump you get over, though. I've been recently doing some long franchise-wide marathons and once I got into the groove it was surprisingly nostalgic. It recaptured that feeling of coming back from school and just playing games until I got called for dinner.
I do understand that when I lose that flow I REALLY lose that flow. Not sure if it's age or distractions or what. All I'm saying is you can get it back and it does feel good when you manage it.
Perhaps you select the wrong games. I kinda stopped gaming for some years. More than an hour was exhausting and most of the games are really boring. Then i rememberd how i loved transport Tycoon and got ottd again. Tanked LOTS of hours into that game. Half a year later i stumbled over factorio again. I bought it in beta and disliked it. Lots or ottd players followup with factorio, so i gave it another try and DAMN iam hooked. Played 60h in the last few weeks, mostly 1-2h hours per day. Its crazy.
If retirement homes don't have videogames when I'm old, I'll lobby for voluntary euthanasia. Aging is a straight negative. Arguments about it making life meaningful are copium. I can have a meaningful life of gratitude without my body falling apart.