Not exactly.
U.S. servicemembers on active duty are permitted to retain their original state of residency, that is, the state in which they were residents of at the time of their initial induction into the military.
This is because it is thought that U.S. servicemembers should not be penalized because they are being sent all over the country (and the world) for the convenience of the government. After all, unlike civilians, servicemembers cannot refuse an assignment–as the saying goes, “That’s why they call them orders!”
That being said, servicemembers who are stationed in a given state other than their original state of residence may switch their state of residence to the new state by expressing a desire to make the new state their their permanent state of residence. In this way, they have the same freedom to establish residence in the state that they are living in, just like civilians. In practice, many servicemembers switch residency to states that just happen to have no state income tax, like Florida and Texas. However, they have to be actuallly living and permanently stationed in the state at the time that they want to switch residency (i.e. not just visiting or on temporary assignment).
When servicemembers separates from the service, they have a time limit to either move back to their current legal state of residence, or establish residency wherever they are living, just like they had moved there.
In my case, I was a legal resident of Texas the whole time I was on active duty in the U.S. Navy, even though I was stationed in Florida, New York, Connecticut, and Rhode Island. I had a Texas driver’s license, Texas plates on my vehicles, and voted by absentee ballot in Texas. When I lived in Connecticut during my time in the Navy, I had no obligation to pay Connecticut state income tax, because I was not a legal resident of Connecticut. However, when I got out of the Navy, I had to switch everything to Connecticut (driver’s license, plates, etc.), and was then subject to Connecticut state income tax, all because I chose to make Connecticut my legal state of residence upon separating from the military. (This decision was primarily because that’s where I found work upon getting out.)