There are 2 problems with your argument:
1. If the goal took priority, then the IDF would not warn civilians to evacuate or tell them where attacks would be so as to allow them not to be injured.
2. Hamas's paradigm is to target the civilians, not see them as collateral to a larger political/military victory. The death of the civilians IS their victory. Their use of their own people as cover and shelter displays the same goal -- intentionally cause the death of non-combatants.
1) you are assuming that these warnings are detrimental to the military-political goals of the IDF, but they may not be. Further, you are assuming a humanitarian motivation without evidence that this was in fact their primary motivation to begin with - there are multiple possible reasons for the IDF to make a big public show of warning the population of the Gaza strip that are orthogonal to your inferred humanitarian motives, such as psychological warfare, or internal or external propaganda; it certainly serves the political goals of the Netanyahu regime to paint their warfare as "clean" and only directed at the political regime of Hamas.
Fact is that they killed a lot of people regardless of their warnings, and fact is that their supporters deem this justified - after all, if these people didn't want to get killed, they would have left their homes and fled to...
where, exactly? The sea? I would consider it mildly farcical to call that the barest extent of humanitarian effort.
2) We often colloquially make a moral distinction between deliberately targeting civilians, and mere "collateral" deaths, but if we examine what "collateral" deaths actually entail in the process of military action, then it looks quite differently: Collateral civilian deaths are deaths that are taken for granted as part of a military action - in other words, a military force inflicting collateral deaths
expects to inflict those deaths and yet still goes through with their military operation.
Therefore, from a moralistic or ethical point of view, collateral deaths are inflicted with deliberate intent; the difference between targeting civilians and killing them collaterally does
not lie in the intent to inflict death upon them, but in the military logic behind it: If civilians are the target, then inflicting more deaths is a military goal, whereas if they are simply collateral deaths, it is not. But in either way, civilian deaths are being inflicted deliberately as part of a military action.
What you are doing here is infer that Hamas' military goal must have been to inflict as many casualties as possible with no higher military-political goal beyond that, but at the same time we are inferring that inflicting civilian casualties is not the primary goal of the IDF.
But the fact of the matter is that both forces are causing civilian deaths far in excess of any possible military targets they might have had at any point during the conflict so far.
In this, we can hold both of them morally culpable;
we can shrug and chalk up the many dead civilians as wartime casualties - after all, we have already established that civilian death fundamentally does not matter morally when victory is at stake;
or we can take one side or the other, saying that one sides' civilian casualties are tragedies and the other sides' are acceptable losses, claiming that one side fights for Good and is therefore inherently Justified in the deaths they inflict, while the other side fights for Evil and is therefore Always Wrong.
(Edit: Wording)