The US military negotiated a secret arrangement with the Taliban that resulted in Taliban members escorting groups of Americans to the gates of the Kabul airport as they sought to escape Afghanistan, according to two defense officials.