My grandpa told me that he did it out of youthful excitement/curiosity and he also thought it could make whites respect him more. In reality, it didn't change shyt in the South (one of his military friends almost was beaten to death by a white mob upon returning).
He fled Alabama and moved to NYC a couple years later.
The only one who was impressed by black soldiers was
Harry Truman, who desegregated the military by Executive Order against the will of his generals and the white population (it was the only way he could do it because it had zero chance of passing in Congress in a deeply racist era)... Dude had balls and it almost cost him re-election that year.
A funny thing though: My grandpa said that his first "relations" with a white woman happened during his deployment (European campaign)