The answer is very simple. Someone at some beginning point chose War as a solution. Having chosen War thereafter it all flows. If at that first point that someone had chosen peaceful resistance then we would not have a War.
I am not a Middle East expert but it is obvious there was a War going on between Israel and Hamas prior to October, 7. It is just the scale of the conflict which has changed.
Israel claims October, 7 was the greatest loss of life on their side since the Holocaust and the Palestinians claim that Israel is engaged in the genocide of their people.
Even if either statement is in some way flawed it was inevitable that when someone made the initial decision to solve their problem by resorting to War eventually this could happen.
If you declare War on someone they will respond and their response is likely not going to be civilised or proportionate forever unless you backdown and even then your actions may have created such hatred that revenge becomes the guiding force behind the other parties continuation of the conflict.