The important part here is that they are forced to actually take the steps of justifying the war to the public and consulting the legislature.
If you have the public’s support for the war, then a war isn’t going to hurt your election chances.
I'm not sure I'd count Trump as a wartime President, though perhaps that's a result of appallingly low standards for what counts as peace.
Engaging in something that can be spun as a just war is a viable re-election tactic.