While Ghandi was in South Africa, that was, before he went back to India in 1915, he offered himself to be a part of the english military along with several other indians. they were reticently accepted into the military as those guys that carry the wounded so that the doctor can treat them. I forget their correct definition so I'll go along with stretcher-bearer.
Why did he do this? Well, he wanted to know his enemy. He despised the British very, very much and wanted to see them gone from South Africa, where he spent a great deal of his life, and India. But what he saw during that time he was in the military, during the zulu-british war was nothing short of eye-opening. Seeing the superiority of the british army in comparison to the zulu made him realize that having an armed revolt against the british was stupid. Very, very stupid.
The 2nd WW was a blessing for Ghandhi because as I said, he actively supported an anti-british campaign in India and wanted indians to NOT be part of the war effort.
If you want the full scoop, you're going to have to read some books. Not all info is on the internet, as some may have you believe. Some costs money.