This is complicated because whether we actively encouraged or actively discouraged soldiers from voting has flipped a couple times over US history.
In the Civil War, Union soldiers were actively encouraged to vote and went near unanimously for Lincoln in 1864 except for the border states.
From the late 19th century to the mid 20th century, soldiers and especially officers were generally discouraged from voting. This started to break during WWII, with some individual states making strong efforts to reach them with mail-in ballots. Those states tended to go stronger for FDR than their neighbors, but military turnout was still abnormally low. For this reason, 1944 was almost surely the 1st election in which more women than men voted.
The soldier vote, where it existed, probably continued to lean Dem until Vietnam. Since then, military voting has been actively encouraged and the military vote became very Republican compared to the general public. In the Trump elections, the military vote has been anomalously close but still Republican leaning. Biden might have won the Navy outright.
Interesting, I actually didn’t realize there was ever a time in which soldiers were discouraged from voting. I guess that was an extension of the same principle behind the prohibition against political activism while in uniform.