Hamas had reportedly begun planning the attack as early as 2017, led by Yahya Sinwar, a key figure who was later killed.