It's possibly a terror tactic they are taught and ordered to carry out. Before October 7th, we know that the IDF had the directive to shoot to maim Palestinian non-combatants. The idea probably being that the others would look at them as examples to avoid.
Or it could be just plain old sadism. For a period of time, the IDF had decided to implement this "humanitarian rule", where they'd call the inhabitants of any building they were targeting with a missile, and tell them to evacuate. They'd call and just say "within the next 30 minutes your apartment will be bombed", and then they'd just hang up immediately without pause. In the beginning a lot of the calls turned out to be false alarms, which made people think it was a prank. Then the warning started turning out to be real, and the people wouldn't evacuate on time. Then, when people started heeding the warning, the IDF would "accidentally" call the neighboring apartment block instead of the one being hit. Then, when people started warning the whole neighbourhood, they'd start calling too early (hours before a strike, to make people exit, then go back in after a while, then be reluctant to exit a second time), or too late (2 minutes before the missile hits, giving people very little chance to evacuate).
There's really little point in looking for rhyme or reason to what the IDF does. The Nazis were doing the same things to the Jews. Some of the attrocities commited were direct orders. Others were initiatives based upon directives. Others were just people feeling like the orders didn't go far enough, and they needed to add their own inhuman flavor. Others thought they were just being loyal, or they were fitting in with the rest of the group. And others were just sadists looking for an excuse to make people suffer.
Whenever this question comes up about the motives of genocidal maniacs, I'm reminded of this scene from Come and See (If you haven't watched this movie, just stop reading, put it from the beginning and watch it).
We like to ascribe logic to these people to make ourselves feel that at least they adhere to some sense and reason which we can fight against, but it's dubious they operate on the premises of logic. Or we like to say they've gone crazy and have become irrational and illogical, because we want to avoid admitting that they used to be normal people, like us. Either way, we should be looking at the effects of their actions first and foremost. Whatever reason the IDF has for doing what it's doing, it doesn't make it any more or less horrific, inhumane or brutally criminal.