Is it because they were moved by the country's non-violent independence movement or is it because they were so severely battered by the Nazi that they could not afford to keep a major army in India anymore and just decided to call their troops away and call it 'giving them freedom'?
It's really because of a combination of several factors, a few of which you have touched upon already.
Firstly, post- 1945, The British found it no longer logistically possible to control and maintain an empire of the size of India which has an incredibly dynamic demographic. This is mainly attributed as being the repercussions of having taken a big part in WWII. In reality, WWII only hastened what would have been an inevitability within the following decade.
Secondly - India, pre-independence was not a country in the sense that we understand it today. It was a collection of a large number of princely states. The British, en route to assuming power over the entire Indian subcontinent, used to constantly pit rival princely states against each other and grant favour to those that sided with them. Gradually, the British even betrayed some of the princely states that aligned with them thereafter unintentionally 'uniting' all of India under the British rule. This can be illustrated by the widespread use of English in India. Even today, English is spoken and understood in every corner of the country. (Which is quite extraordinary in a land of over a 100 languages and dialects)
This unintended sense of unity that they fostered was an important happening that led to discontent with the British. This was given further impetus by the freedom movement that had been gaining in momentum.
With this background, it is possible to imagine the sheer difficulty of the task of instilling a nationalistic spirit and glavanising people to rebel, non-violently, against an empire. The non-violent movement would therefore, in this light, be deemed successful because of the "Us vs. Them' concept that was used to create a strong national identity.
Before I end this post, I would like to take the time to clear up another misconception about the Indian freedom struggle. This is with reference to the misconception that once freedom was sought, the British packed up and moved back to England and that was the end of British association with Indian administration. This is generally the right-wing Indian political narrative and it ignores the many good things that came out of the British rule in India. (hospitals, schools, railways etc)
It may be of interest to note, that the current ruling party of Indian Govenment was established by an Englishman (A. O. Hume) so that India could have some political representation. This was even before independence. Post independence, the painstaking task of inttegrating the hundreds of princely states was done by Sardar Vallabhai Patel with the assistance of a Lord Mountbatten. Examples of these are various.
TL;DR - A combination of factors. WWII, the freedom movement
I sincerely apologise if I have left out something and I feel I may have. This is because I am typing this on a phone on my long way to work. I'll be more than happy to take any follow up questions.
For further reading I would recommend Pt. Nehru's "Discovery of India" and Ramchandra Guha's India After Gandhi.
edit: formatting