Gaza has been under military occupation by Israel since 1970 (including after the disengagement in 2005; the blockade is very much a form of military occupation). Being attacked by the people you're occupying is the obvious outcome, setting aside the specific details of the attack because I know Hamas did some unspeakable things in Oct 7. If Israel wanted to protect themselves they'd stop their occupation of Palestine and retreat to 1967 borders.