Natural selection is a greedy algorithm. Being forward thinking or altruistic rarely produces more surviving progeny over the short term.
It's not altruism to try to avert long term disaster beyond your own life span. It's in your own interest to ensure your progeny survives - even several generations in the future they still carry your genes. But I don't know if inbuilt mechanisms for this exist in evolution.
I'd like to think self-inflicted extinction isn't a likely outcome of evolution - but maybe it is once a certain species dominates.
I wonder if this ultimately also happens on other planets with carbon based life (if they exist) - a short period of hyper growth once life learns how to unlock energy from the past, followed by extinction.