The Taliban are a military and political group compromised of an ethnic minority in Afghanistan. It's not even that the US lost to "goat herders with guns". We failed to secure a small country against a well organized, armed minority.
No insurgency like that can exist without foreign support in some form, usually from governments but it can be from resource export.
And the reality is nobody has ever defeated a foreign sponsored insurgency. Some have ended because the sponsor quit sponsoring them, but that is not the same thing as defeated.
Nobody has ever defeated a foreign-funded insurgency, other than by the funding going away. It's no surprise we didn't accomplish what nobody else has, either.
Everyone knows Pakistan funded the insurgency. Pakistan has no interest in actually running Afghanistan. It's a buffer state for them. The US has no real interest in trying to get Pakistan to stop this. It's a failure of domestic politics that we didn't drop pack up a few weeks after it became obvious Bin Laden was not there.
On the flip side in any domestic insurrection, the soldiers know the terrain, language, customs and culture of the people, the supply lines are nothing (rather than having to airlift materiel and people thousands of miles, you drive them on regular roads), the infrastructure supports espionage, most people support the regime and will collaborate to return to stability (since they voted for it), the regime never leaves (you can leave Afghanistan, you can't leave your own country or it ceases to be a country), and if you lose, you lose territory and/or politicians run the risk of violence. The stakes are why these comparisons are never relevant.
Then the americans tried. They were not goat herders. They failed.
The pattern is clear.
So, if one sees the whole of IRGC plus Basij as the "commandos", they alone form an active elite of about 0.5%, if one sees the entirety of the military+police we're looking at easily 2-3 million units, so up to 2%.
[1] https://en.wikipedia.org/wiki/Islamic_Revolutionary_Guard_Co...
[2] https://en.wikipedia.org/wiki/Islamic_Republic_of_Iran_Armed...