Interesting. You are supposed to need to opt in. That’s the whole point of war mode. However I know for certain some passive aoe abilities bug out and will hit enemy players already flagged for pvp, and pull you into being pvp flagged as well.
I first experienced it on my enhancement shaman in early dragonflight. I raised it in the bug forum. Several times as it continued to occur throughout the expansion. It was still occurring during superblooms, so it was never resolved. Not sure about now.
Found my thread about it.