The attack underscores Afghanistan’s security issue as the country prepares to take over from foreign combat troops after more than a decade of war against a Taliban insurgency.