Gandhi was in South Africa as an activist in the movement for the rights of the Indians there.
Step-by-step explanation:
Gandhi was a practitioner lawyer who had studied in England.
1. From thereon he went to South Africa and spent a few years there rallying people to the cause of non violent protest against the British.
2. Gandhi asked the magistrate to increase his sentence because his fellow protesters were getting sentenced for more and he did not want to get away with less than them.
3. Gandhi would spend close to a decade in prison during various times in the freedom movement and use that time for writing and formulating his doctrine.
He has an enormous corpus of writing.
4. He could use personal time in jail to formulate these strategies of non violent protest and satyagrah that have been relevant since