Residency rules vary from state to state. For example, if you spend more than a certain number of days in some states, you're considered a resident even if you were not living in the state for very long.
It's best to check with your State Department of Revenue for specific residency rules, especially as they apply to your particular situation. In the meantime, use the examples below as a general guideline.
Here the rules are pretty straightforward. Your Home of Record (the state you enlisted in) is also your State of Legal Residency (SLR) no matter where you're stationed, unless you submitted paperwork to change your SLR to somewhere else. There are also rules for military spouses.