But what if intentionally blowing up a hundred civilians saves a thousand more? That's one argument used to justify the bombing of Hiroshima and Nagasaki for example, and the carpet-bombing of Germany. Many people have also disagreed with those arguments, but especially in the case of Germany it kind of was of a "kill some civilians to save many more" type of trolley problem – the greater Holocaust effort was stopped in more or less the earlier rather than later stages (I'm not very familiar with the Pacific war, so less comfterable commenting on that).
And what is a "civilian" anyway? Is someone who works in a gun factory a civilian or are they a legitimate target? What about a jeep factory? Or a factory which produces just some parts? What about the factory that provides steel? What about the lorry driver delivering the steel? Is someone who actively works to spread disinformation to justify something like the Russian invasion a civilian? Does it matter if they genuinely believe their own disinformation or if it's proven they know it's false?
In principle I agree with you as such and I think very few people disagree, but it's all pretty murky because most modern wars consist of much more than just soldiers going at each other. You need to look at the specifics of the situation in every single case.