To the extent that Hamas targeted the military, that is very much legal, and an exercise of the right to resist that is granted to people under a belligerent military occupation. The tactic of capturing civilians as hostages is a familiar one in conflicts, but that makes it no less criminal, and given some of the targets, including very young children, no less horrifying. The extensive targeting of civilians in this attack is not covered by that right to resist. While Hamas, with its relatively primitive rockets, often has little ability to distinguish between civilian and military targets, they clearly could have in the ground assault on Saturday. That was a decision Hamas made, and it was not an acceptable one.
None of that, however, justifies cutting two million Gazans off from food, water, and electricity, or the willful bombing of civilian sites that have included hospitals, shelters, marketplaces, and other sites that have nothing to do with Hamas. War crimes do not justify more war crimes. The US enabling this is the US doubling down on what brought us all here in the first place.