It is 100% legal to bomb targets that have dual use (both civilian and military). That is why it is 100% legal for Ukraine to bomb the kerch bridge. It is a bridge used by both civilians and military.
Israel didn't bomb a hospital, that was a misfire of their missile. Israel showed that a different hospital is actually used as a base of operations for the Hamas because they know Israel won't bomb it.