If you refuse to go to war with Hamas because of this fact, you incentivize that behavior.
I can't really think of a more just case for war than "the government of a neighbor just brutally, intentionally slaughtered civilians in a surprise attack in our country." It doesn't matter whether the neighboring country is a dictatorship or a democracy.
It very much sucks for the people of Palestine that Hamas chose to start a war with Israel and is using tactics that purposefully result in the death of Palestinians. I hope that they stop putting rocket launchers in and next to schools. I hope that they start allowing people to evacuate. I hope that they stop lying to their people about "psychological warfare" in an effort to get more of them killed. I wish that neighboring countries would allow Palestinians to escape the carnage, and adopt strategies that actually support the Palestinian people rather than the Palestinian cause.
But the IDF and Israel do not control that. And I'm honestly not sure what people expect from them. If you can't fight an enemy that hides behind civilians, then hiding behind civilians is an obvious winning strategy. And personally, I don't want to live in a world where the government most willing to sacrifice their own people automatically wins any conflict.