Generalising this principle is quite naive.
With some actors - yes, pacifism is the better way.
With other actors - pacifism will only get you killed; the obvious example being WW2 Axis powers: if the Allies would have adopted a pacifistic position, the nazi would have just killed everything in sight, as they repeatedly proved.
For a more contemporary example - non-violent opposition did not work so well for the syrians.
RL examples, of course, go both ways. Star Trek just dares us to imagine otherwise. I.e. that the Nazis are horrible but maybe this whole thing could have been prevented if we'd figured out how to keep Hitler from power (or even, way back when, negotiated that going to war over six drunken guys killing an Archduke was moronic). War may be necessary but glorifying it tends to beget war.
I do, however, note that Deep Space Nine could never really come to a conclusion on the reality of a just war. Sisko and Odo resolve the Founders conflict by making peace with them but that's only AFTER they've been threatened with annihilation. The carrot, in this case, was useless without the stick.
Which may be an answer by itself, albeit a troublingly non-Trek one.