In the worst incident, Taliban militants stormed an army post in the western province of Farah, killing 22 soldiers.
Defense Ministry spokesman Dawlat Waziri said two Afghan soldiers were also injured in the 3 a.m. raid on a small base in Balabluk district.
The attacker hit Kabul's Shash Darak area on Saturday, Afghan Interior Ministry spokesman Najib Danish said.
The Afghan Army and police have repulsed Taliban multi-pronged attacks against the provincial capital Farah within the past months as the militants have been trying to capture full control of the city and outer parts.
A Farah provincial council official Dadullah Qani told Tolo News the Taliban also captured two soldiers and stole a large amount of weapons.
Islamic State claimed responsibility in a message carried by its Amaq news agency.
The resurgent Taliban and the newer IS affiliate have been blamed for increased violence in Afghanistan after US and North Atlantic Treaty Organisation forces concluded combat missions in 2014 that began after the 9/11 attacks in the U.S.
A wave of attacks across Afghanistan has left more than 25 people dead, majority soldiers, officials say.
Seven civilians were injured in the attack, Zwak said.
An Afghan official says at least three security personnel have been killed in separate suicide bombing attacks in southern Helmand province.
The blast killed at least three people and wounded a half-dozen others, he said.
Earlier on Saturday morning, a militant detonated an explosive-laden hijacked military armored vehicle at an army camp in Nad Ali district, west of Lashkar Gah, killing two soldiers and injuring another one, according to Rahimi.
The group had called on the "American people and the peace loving Congressmen" to pressurize U.S. leadership to end the occupation of the Asian country, a precondition that Taliban has always maintained to begin any negotiation.
Recently, US President Donald Trump authorized a troop surge in Afghanistan, a policy that had been tried out by former US president George W. Bush but had failed to end the Taliban militancy.