Now, the military does have regulations to prohibit soldiers from disrespecting the flag...and the presidency.
Even then, the military has severe boundaries on inhibiting the free speech of soldiers. For instance, a soldier--in uniform-- can speak negatively about a president as long as:
A. He does not use "contemptuous words." That is, he can say, "The president's statement is untrue," but he cannot say, "The president is a liar."
B. He does not make statements leading to or implying a justification for acts of mutiny, particularly if he is in a leadership position.
Now, the point I'm making here is that even being in the military does not totally abrogate the right to free expression. That's how resilient the First Amendment is.