Perfect analogy except instead of killing the attacker and bystander to get the hostage you also take out 40 other bystanders in 200m radius and just to be sure level every building in that radius to the ground.
Of course a simplistic analogy won't be good, on either side. In reality it's not a lone attacker, it's a paramilitary that is also the governing body of Gaza. It's not like a cartel invading Texas - it's like the Mexican government sending its army to invade Texas, then hiding its army amongst civilians.
And it's like this is happening in the broader context of the Mexican government believing that the US has stolen its land and trampled on its rights for the last 75 years.