After a decade of training Afghan military pilots in the United States the Americans have decided to train all Afghan pilots in Afghanistan. The problem was that more and more of the trainees deserted while in the United States and many sought to gain legal residence as asylum seekers in Canada or even the United States. This is not a new problem, the first pilot trainee desertions took place in 2015. Eventually, over 40 percent of the pilot trainees deserted while in the United States. It is not much better in Afghanistan where the government accepts desertion by soldiers and police as a normal, if annoying, custom. The Afghan Air Force has additional problems.
In 2015 the Afghan air force had 7,000 personnel and 90 aircraft with about 70 more on order. Even then the problem was not aircraft but Afghans qualified to operate and maintain them. Afghanistan already had hundreds of military pilots but not enough to operate some types of new aircraft (AC-208 and A-29). Thus there were four C-130 transports but only enough qualified Afghans to provide one crew.
The U.S. continues to provide training for hundreds of new pilots and maintainers in Afghanistan but some types of training were, in theory, cheaper to carry out in the United States. The training program in the United States was meant to make the Afghan Air Force able to handle all current and on-order aircraft. The problem was the tendency for technical people, like pilots and maintainers, to leave the military for better paying and safer jobs in the civilian sector. Even if you try to enforce service contracts it is common for military Afghan personnel to simply desert when they have enough money to pay a people smuggler to get them to another country, preferably in the West. Meanwhile, the only option is to hire more expensive foreigners to fly and maintain aircraft. Officially that is not done. Afghanistan is a place where many consider Western education an offense against Islam and those who seek such training in Afghanistan suspect. If the Taliban have done nothing else they have convinced several generations of ambitious and hard-working young Afghans that achieving success through more education is not widely accepted in Afghanistan, but the financial rewards for the well-educated, especially when it involves technical skills, are much higher in other countries, especially in the West.
The U.S. tried to screen trainees for the America based program but the desire by educated Afghans, especially young ones to leave Afghanistan was too widespread. Young Afghans with technical skills realize that the culture of corruption and power of the drug gangs and religious conservatives (not just the Taliban) in Afghanistan meant there were not enough opportunities for them and prospects were better in the West, or even Iran and the Persian Gulf. Iran had its own problems with corruption and religious restrictions. Jobs in the Persian Gulf required legitimate travel documents. Moslem nations are much stricter about letting foreign Moslems in and give preference to non-Moslems when hiring skilled foreign workers. Afghans have a reputation for being diligent barbarians, but that is a generalization. Many Afghans want a better life that does not involve being a murderous outlaw. The best way to accomplish is to hit the books and then hit the road.