I think it is difficult to understand religious/political fanaticism because so much of it is anti-social and defies the normal standards of living as a cooperative human. Terrorists are never rational actors, and they seem to operate with an 'ends justifies the means' thinking, including their own deaths.
I don't think Israel is totally blameless. They have been resistant to cooperate in recent years, and the tensions have been increasing as an example. The intelligence failures on Israel and the USA is notable here. How Hamas got so many weapons and created a plan without detection is a huge question. How they got these weapons is another question, and that can ripple to other nations in a regional war. I think it was a mistake from a military perspective because Hamas poked a bear. They won't win, and they don't have much support in the world, especially by taking hostages. Frankly I don't think many hostages will survive. My guess is the hostages is two-fold: that they can inflict terrorism in the form of making Israel think twice about tactics, and using them as human shields.
I'm surprized Israel dropped the ball on this. It could have been due in part to their divided society and corrupt government, as that scenario makes patrioitism and duty a difficult commitment.