Correct me if I am wrong, Ihaven't read the "rules of war" in a while but if a combatant uses a civilian structure or hospital, etc. for a military prupose it can be designated as an acceptable target.
IIRC Ukraine got accused of this when they put anti tank weponry near a hospital (or something like that) and Russia hit the hospital with artillery and was admonished of this because Ukraine had made the area into a military site.
I will look it up later, I'm late for a dinner.
It's not that simple. There is no "but they started it" doctrine in the rules of war.
There are 3 considerations: proportional proportionality analysis (yes, it's a reductive name, take it up with the lawyers), non-reciprocity, self-defense. These come from the 2 primary statutes: the Geneva Conventions governing the treatment of victims and the Hague Conventions governing the conduct of armed forces. The armed forces in question, be they Israel or Hamas, do not need to ratify for the Conventions to apply; they are universal.
1. Doctrine of Non-Reciprocity
It is unlawful to attack any protected (i.e. protected under the Geneva convention - schools, hospitals, etc) target merely out of revenge or lust for battle.
2. Self-Defense
Attacks against a protected target in response to an active and ongoing threat which is clear and present, even if the attack is pre-emptive, are lawful.
3. Proportional Proportionality Analysis
Any action with defined military objectives where the savings of lives and materiel as a result of said action exceed the loss of life and materiel are lawful (note that for something like a hospital one must consider ongoing losses caused by the loss of life-saving personnel and equipment).