Earlier quoted context omitted.
You cannot declare war on a territory you occupy and control. It is as if the United States declared war on Washington DC or any of their numerous prisons.
Israel neither occupied nor controlled the Gaza interior prior to Hamas' attack. They only controlled the border and what goes in and out of Gaza (some cross border tunnels excepted). Within Gaza, Hamas and the Palistinian National Authority ruled.
"only" is used here to diminish the suffering of the Gazan people. Israel has had Gaza under a brutal blockade, across air, land and sea. They control everything that enters or leaves, and infamously were so cruel they counted the calories entering Gaza [0] [1]. Israel even claims control of the air over Gaza, and prevents civilians from collecting rainwater [2] [3] [4].
Israel has been enforcing collective punishment for decades - they want that land, and they want it only for themselves.
[0] https://www.timesofisrael.com/israel-counted-calorie-require...
[1] https://www.nytimes.com/2012/10/18/world/middleeast/israel-c...
[2] https://www.amnesty.org/en/latest/campaigns/2017/11/the-occu...
[3] https://www.haaretz.com/opinion/2016-06-22/ty-article/.premi...
[4] https://www.aljazeera.com/opinions/2014/3/10/debunking-some-...