This may seem obvious and inevitable. It's not and only appears so in hindsight. Nothing in life is inevitable. If you want something to happen, you need to make it happen.
I've held marketing and media leadership roles. But I've been teaching myself to code for fun and realized I might need to focus on more technical roles when I found myself doing things like reading the OpenRTB and AdCOM API docs for fun, and hanging out with engineers and data science folks more than fellow marketers.
Would you mind sharing what sort of role you're in now and how you went about that pivot?
Once you're over 40, life becomes lived inside the margins of things that are inevitable, such as physical decline and, of course, ultimately death. The plays out by the shortened timeline and more painfully by the disappearance of parents, loved ones, and colleagues. There is a lot of important things in life that are indeed inevitable.