Have we morally failed Afghanistan?

The point is, who set up, trained, equipped, and funded the Afghan army in such a way that it was not possible for it to function without US support? And then pulled the plug?

It was set up so that it could never fight independently. The whole structure was based on highly paid contractors supporting high-tech equipment, and supplying logistics. When the US switched that off, they were left without even ammunition for their rifles.

They assumed that the contractors would remain, and the US would continue to support them, even after pulling out.

They found out that they were being totally abandoned only a few weeks before the pullout. Bagram was the turning point.