Franklin Roosevelt and Harry Truman served in WWII as Commander-in-Chief—as did Abraham Lincoln and Andrew Johnson during the Civil War.
The relationship of presidents to their military is no different than that of a mayors/governors to their police departments: While they are in command of their military or police - the latter are not serving in the police and former are not serving in the military.
Don't believe me, look it up!