My impression has been that midlife crises usually develop with people who neglect to make fulfilling choices earlier in their lives. By the time middle-age rolls around, they reflect on the thought that they've spent half their lives missing opportunities. Consequently, they they have an urge to realize fantasies that never came to fruition.
I think it's possible to avoid midlife crises if you think ahead, sort yourself out, pursue ambitions that have meaning to you, and devote your energy to the extent that it's conscionable and reasonable for you. Fortune has to favor you for the ducks to line up in a way that you can work with them. You probably have to have a satisfactory amount of appreciation for your lot in life, too.
Nevertheless, there's still a chance that the existential anxiety of middle-age shifts your attention toward some "missing piece" that leads you to question everything, regardless. Maybe a person who spends their time trying to avert a midlife crisis has a chance of incurring a midlife crisis in the process. "Think of all the opportunities to fuck off from life I skipped out on!" etc.
Well, I've read lots of different sources on this and the most consistent themes are to do with a recognition that what you want to do, ambitions, are not matched by opportunities, it can either be a ramping of the former or the later which causes it, ie you still want to do as many things as you did but your health is failing, that's no change in the former but a decline in the later, or you're older and have a better idea of what life can offer than when you were younger but have responsibilities you did not have when you were younger, that's a ramping of the former and no change of decline of the later.
That's maybe not explained well, my point is that its not just a case of regrets as I understand it.
You could well experience a crisis if you have alienated much of your life, Marx used to write about that, a big bank saving account was a sign you had not spent the money actually living, so it was a record of all the times you have failed to wine and dine friends for instance. However, I hear more people regretfully or ruefully talking about time and money spent that way instead of saving it and there's so many books written encouraging people to value or feel as good about money saved as money spent.
Some of it I think is a game of bad comparisons, I dont really compare myself with others in the way that I've read many people are doing and judging themselves as wanting or deprived. Instead I usually compare myself with people who are much worse off than myself, then I'm grateful for what I do have, I've always done that. However, one of the people who have written on mid life crisis has written about how setting goals and achieving them is self-defeating as when goals are achieved they are achieved, that's it, you can only have one first time at anything, even if you want to repeat a goal its done, if that makes sense. And they say a lot about that.