> The idea that in a war there can be legal and illegal actions established by international treaties to protect civilians as much as possible can only work if two (or more) legitimate states are fighting each other

This is not true (the laws of war work and have been applied successfully in conflicts not involving two or more legitimate states) and it's an assumption that seems to have negatively informed the questions that followed.

> with leaders who can be held accountable for the orders they give.

Holding leaders accountable ("legitimate" political leaders, terrorist leaders, rebel leaders, we can do it) is good, but we also hold individuals accountable.

> But does it still make sense to talk about legality and international treaties when on one side there is a terrorist organization whose method of warfare consists of kidnapping or killing civilians?

Of course it does. The notion that one side is no longer accountable for harm done to civilians in violation of the law because the other side has harmed civilians in violation of the law is wrong.

> At this point, doesn't complying to international treaties only mean further endangering their own population?

Sometimes yes. It certainly does put troops in danger often enough. Everyone who is party to these treaties is well aware that a country could be safer in a conflict if they just quickly incinerated the other side, and they've chosen to be bound by these laws anyway.

This operation was one of the most targeted military operations known in warfare. International law doesn't hold Hezbollah accountable for example. That is the reality today.
Hezbollah's own actions are significantly more targeted and have resulted in significantly fewer civilian casualties.
This is just luridly false, especially (but not exclusively) in the context of Hezbollah's own actions in Syria, where they made and broadcast propaganda videos of them deliberately starving Madaya. When you make claims like this, you call into question everything else you're saying; it's hard to imagine where you could have gotten this notion from.
We’re talking about Israel, not Syria.

It's equally true in Israel, where Hezbollah fired tens of thousands of rockets indiscriminately, killing, among other things, a Druze children's soccer team in the Golan Heights. You can read this on Amnesty (no friend of Israel's) if you want.

Again: it's hard to understand where you could getting this notion that Hezbollah attacks are highly targeted from. That is anything but their operational signature.

I posted plenty of videos in my other reply to you of Hezbollah attacks on Israel. They’re very clearly targeted.

They fire guided munitions at Israeli troop positions. They fire unguided rockets and mortar shells into Israeli towns. A video of a targeted Hezbollah strike doesn't illustrate anything at all; everybody points the gun when it's useful to do so, it's what you do when you don't have a combatant target that tells the actual tale.

I can't say enough how odd it is to bring this kind of take into a discussion about Hezbollah. Note that I'm not making the case that Israel is fastidious about avoiding civilian casualties; that would be an unproductive argument to attempt on this thread. You have found one of the few arguments that are even less productive.

https://www.amnesty.org.uk/press-releases/lebanon-hezbollahs...

Lebanon: Hezbollah's rocket attacks on northern Israel must be investigated as likely war crimes

We are Amnesty International UK. We are ordinary people from across the world standing up for humanity and human rights.

Any collateral damage here is orders of magnitude less than what Israel has done. There’s no debating that.
I don't have to debate that point, because it addresses an argument I didn't make. The problem is how deeply unmoored your argument is from reality. Exactly why is it that you believe Hezbollah's attacks are characterized by a high degree of targeting? It's clearly not true. Can you explain the logic and the sourcing you used to make that claim?
I already explained it with video evidence. I’m not sure why you hate Hezbollah so much, but I don’t share your animus. In fact I’d consider them an ally from an enemy of my enemy perspective. You don’t have to agree, but that’s my POV.

You didn't, at all. I didn't look at the videos you provided; I simply stipulate that they're real and depict what you say they depict. That doesn't demonstrate anything at all about Hezbollah's rules of engagement. When they have a clear firing solution on an IDF tank, they take the shot? Ok. And?

At the point where you're declaring Hezbollah a moral ally, I think the conversation has run to its logical terminus. Ask the Sunni Arabs in Syria how allied they feel with Hezbollah.