Afghanistan said the soldiers were killed in response to what it called repeated violations of its territory and airspace.