Parties to a conflict shall at all times distinguish between combatants and non-combatants. Attacks shall be directed solely against legitimate military targets.
If you look up the definition of military targets you will see
“In so far as objects are concerned, military objectives are limited to those objects which by their nature, location, purpose or use make an effective contribution to military action and whose total or partial destruction, capture or neutralization, in the circumstances ruling at the time, offers a definite military advantage.”
You can ask pretty much every lawyer that Hamas actually made the hospitals into legitimate targets under the Geneva Conventions. The only party that clearly broke that law without a doubt is Hamas.