It has been said many times that while bombing a hospital is normally a war crime, there are exceptions which is why it is important to wait until all facts are known before labelling events war crimes (it is for courts to decide after the war).
What does humanitarian law say about hospitals?
According to Mathilde Philip Gay an expert in international law, “It is forbidden to turn recognised civilian hospitals into a conflict zone. It is also forbidden to use civilian populations, the sick or the injured as human shields, it is a war crime, as is fighting from inside a hospital.”
But it makes an exception if the targets are “military objectives”. Philip-Gay said that “if a civilian hospital is used for acts harmful to the enemy, that is the legal term used”, the hospital can lose its protected status under international law and be considered a legitimate target.
It is widely accepted that Hamas has an extensive tunnel network across Gaza.
Karim Khan, the chief prosecutor at the ICC, wrote in the Guardian: “For those responsible for targeting and firing missiles, I wish to be clear on three points in particular.
One: in relation to every dwelling house, in relation to any school, any hospital, any church, any mosque – those places are protected, unless the protective status has been lost because they are being used for military purposes.
Two: if there is a doubt that a civilian object has lost its protective status, the attacker must assume that it is protected.
Three: the burden of demonstrating that this protective status is lost rests with those who fire the gun, the missile, or the rocket in question.
“In this context, I would also underline that the indiscriminate firing of rockets from Gaza into Israel may represent breaches of international humanitarian law subject to the jurisdiction of the ICC.”
https://www.theguardian.com/world/2023/nov/17/can-hospitals-be-military-targets-international-law-israel-gaza-al-shifa