The President has immunity when acting with powers granted from the Constitution. Commanding the military is one of those powers. The majority opinion also specifically says motives can't be considered. So they are legally immune if they order the military to stop impeachment.