Some examples of war crimes against hospitals committed by militaries.
Nazis and Allies (WWII)
At the start of the war, Germany bomb the Polish town of Wielun. One of the first building to be destroyed was the town's hospital. Allied and Nazi terror bombing of civilian areas of cities included the destruction of hospitals. Defenders of these militaries call it collateral damage due to the imprecise nature of the weapons of the time however there is evidence of the deliberate targeting of hospitals. In the Pacific both the US and Japan attacked clearly marked hospital ships - two Japanese hospitals were sunk.
Bosnia and Serbia
During the Yugoslav Civil War, hospitals were a prime target. Serbs deliberately shelled them in Sarajevo and Zagreb. NATO attacked 20 hospitals during its 78 day bombing campaign against Serbia.
In 2014, Israel announced their intention to bombard the Al-Shifa hospital in the Gaza Strip. It was one of three hospitals deliberately targeted by the IDF during their war against Hamas. Israel, of course, claimed all the attacks were accidents.
Russia bombed a hospital in Hama, Syria last week. Last year, Syrian forces bombed a hospital in Aleppo. They are but two of several Syrian hospitals to have been attacked.
In 2003, US forces used their smart bomb technology to blow up a maternity hospital in Baghdad. In 2015, the Iraqi Air Force bombed another maternity hospital, this time in Fallujah. In between, many other hospitals have been shut down due to the tactical application of explosives.
Both Russia and Chechen rebels have attacked the others hospitals. The rebels have been more aggressive in targeting hospitals.
Again, all sides see hospitals as easy targets. The Taliban has attacked hospitals as well as the Americans.
The American attack on the hospital in Kunduz, Afghanistan was deliberate. The Afghan government wanted it attacked and the US military was more than willing to comply. The context of events and the weapon used are proof of that. The US knew of the hospital and its location. Afghan forces had previously invaded the hospital. The AC-130 gunship that carried out the attack is a line-of-sight weapon. It has to see the target to hit it, hence it had to have seen the target was a hospital. The conflicting statements by the Pentagon is merely clumsy ass covering.
No truthful reason for the attack will every be made public but the reason can be easily deduced. The Afghan government viewed the hospital as providing aid and comfort to wounded Taliban fighters and civilian Taliban supporters. They wanted the facility destroyed to ease their attempt to reconquer Kunduz.
US military personnel consider the Afghan people "sub-human, coward scum" to directly quote from a soldier's Facebook page. So, bombing an Afghan hospital is less concerning to them than if they had been ordered to attack a veterinary hospital.