When there is poverty, there is the drive to do whatever it takes to feed house self and your family
Evil people, such as the Taliban, are able to exploit those living in poverty- either by forcing them to do things they don’t want to (otherwise they’ll kill them) or by offering them a lifestyle which gives them the means to support their family eg grow/transport drugs (exactly same happens in Central America where poor farmers make far more money from growing drug industry plants rather than food)
Obviously there is the whole religious fanatic aspect too. So Saudi Arabia needs to be tackled as they are ruled by despotic billionaires who have basically allowed the Wahhabi (extreme Sunni) clerics to enforce strict Sharia as long as royal family can do whatever they want (it also helps that the royal family remunerate the clerics handsomely). Part of the deal With the clerics is that the Saudi royal family funds extremism in other countries such as Pakistan and Afghanistan.
And then you also have to consider that Pakistan has huge control over Taliban (well Taliban have huge control over Pakistan) and Pakistan are supported by Chinese (who helped them develop nuclear weapons) as the Chinese don’t like India and Pakistan want Kashmir from Indian government and Russians are friends with India so they are happy to help Indians support Afghans to continue to make life hard for Pakistan.
So a combination of legalising drugs (removing Taliban main source of income), remove the al-Saudi family as rulers of KSA thereby slowing the spread of islamism, sort out Kashmir. Make friends with Russia and China so both countries stop using Afghanistan as a pawn in their games.
So really straightforward
(Please note though I have taken a slightly flippant tone, thisnisnnotnbecause I think this is in any way funny. It is a desperate situation and frankly I don’t know how it can be solved as it has so many aspects to it (and there will be many, many more I’ve not mentioned*). But going back to my opening sentence, reducing poverty ie fairer distribution of wealth has to be the end game. Which means reducing wealth of the extremely rich. Which won’t happen.
*Other factors I may have missed: extremist Christians in USA, Israel (this gives every extremist Muslim a “cause” that justifies their actions), security of water….etc etc
Caveat: I am a complete history/politics amateur but the only books I read relate to Middle East/Afghanistan/Iran. The other country which we need to feel very sorry for now is Lebanon. There is too much sadness, too much cruelty and too little compassion and empathy.