The officials spoke on condition of anonymity because they were not authorized to publicly discuss details of the attack, which is the latest in a string of incidents in which Afghan troops turned their weapons on their supposed allies.