KABUL—At age 21, Niloofar Rahmani became Afghanistan’s first female fixed-wing military pilot, living out her father’s dream and emerging as a symbol of her country’s revolutionary assent to roles for women outside the home.

That was also when her life began to unravel. “This was my dream job,” the Afghan Air Force captain said. “I never thought I would want to quit.”

Now...