I wish it were true that it's not often Israel gets accused of this sort of thing.
Of course they were woefully underprepared. They completely underestimated what Hamas and the Gazan civilian mobs were capable of.
Netanyahu's policy regarding Hamas (see below as described by the woman posting the Israeli Jewish AMA thread that no one ever reads) seriously backfired. But dealing with terrorists usually does, so it's hard to know how he should have played it.
Overseas, most people joined the story on 7 Oct and saw Netanyahu just using a very harsh "stick" against Hamas. In Israel the criticism is exactly the opposite: Netanyahu spent the last 14 years offering every possible "carrot" to Hamas, strengthening them, allowing them to get huge amounts of money from Qatar, giving work permits, in order to play them off against the Palestinian Authority, and because he believed they would restrain their terror ambitions if they had economic incentives. In retrospect, that was not a successful policy (understatement).
I don't think there are any carrots to be offered to Hamas at this stage. I understand that Netanyahu's strengthening Hamas was part of a power play and not some kind of partnership with them, but by now they have made clear what they are about, which is a disaster for Israel and even more so for Gazan civilians, who have suffered both Hamas's rule and Israel's response.
https://www.mumsnet.com/talk/AMA/4967191-im-a-jewish-israeli-ama?postsby=israelilefty&page=4