Terrorists attack Israel, Israel responds to terrorists, terrorists rearm and fix their infrastructure so they can commit more acts of terrorism, rinse and repeat several more times over the years.
The solution is for terrorists not to attack Israel in the first place. The root problem is that Palestinians deny Israel's right to exist, which means Palestinians don't want a two state solution, only a one state solution, without Israel. If there is ever going to be a two state solution it has to include Israel and it has to include security guarantees that Hamas and other terrorist organizations aren't going to just rearm and build infrastructure for future terrorist attacks and they are not capable of that. The Palastinians need a credible leader who is not a terrorist and won't let terrorists get a foothold on them and is willing to live in peace with Israel.