This is a very effective use of the trolley problem to help clarify thinking about a real life issue. I don't think this question has an easy answer, but this is what I have come up with so far. The Israelis could say that there are more children on the train tracks than you have counted. If Hamas continues to exist, then they will kill an indeterminately large number of people in the future. Consequently, killing a small number of people now will save a large number of future Hamas victims, and is therefore as morally justified as killing one fat man to save several people stuck on the railroad tracks. (leaving open exactly how justified that is.)
My problem with this answer is that the Israeli government's actions will almost certainly not destroy Hamas. On the contrary, those actions will probably recruit several new Hamas members for every person they kill. This argument will fall on deaf ears, however, because angry people usually prefer doing something that doesn't work to doing nothing at all.