That wasn't legalised killing, although in international law, and if Hamas had only killed IDF it would have been legal, as fighting for freedom. They were attacking their oppressors. Sadly, many were out of control with a weapon in their hands and wanted revenge for their families killed by Israel.
Just like IDF and civilian Israeli attacks on palestinians. Although in the West Bank it's killing in the process of theft.
I suspect that the Hamas perpetrators involved in the 7 October incursion have already been summarily executed, along with their families, neighbours, friends, doctors and patients in nearby hospitals, nearby ambulances and anyone else who happened to be in the vicinity