One minor correction - it was technically released as 4 states. The Princely States were allowed to declare independence, along with the options or join India/pakistan. Hyderabad opted to, and was promptly invaded and annexed by the Indians.Sikkim also voted against union with India. In 1950 they became an Indian protectorate, and in 1975 India invaded on the request of the Prime Minister (Sikkim was still a monarchy) and after a somewhat controversial referendum, it opted to join India.
I don't feel qualified to answer your question directly, but I hope this provided some useful additional background info.
The nationalist movement (led by the then Congress before its later splits and the rise of opposing movements) was strongly for one big country, and the British (who generally preferred chopping territories up - Ireland, Palestine, Nigeria; even little Ghana was on the block for a while) for once relented in the face of local opinion, for a time - though even that involved keeping some power for the princely protectorates.
World War 2 changed a lot: Congress opposition to the conflict and Muslim League readiness to support the war effort tipped British government opinion from 1940 into acceptance of self-determination on religious grounds, something hitherto unfamiliar outside Ireland - and that didn't turn out too well either.
There's a lot involved: Britain didn't like the idea of big united ex-colonies (even though they became allied to one), and had encouraged the Muslim League's creation in 1906 as a counterweight to Congress (which had just called for home rule). In 1940 Britain faced a strategic emergency, and Congress was unwilling to help out.
Congress has been accused of miscalculation, the League of sectarianism and opportunism: wartime British weakness also had a part, but so did a tradition of plonking national boundaries in territories which they'd previously been content to rule as a whole: "They can live under us but they can't live with each other."
Let me try again to explain this . Initially the Indian Hindu and muslim populations very largely peacefully co-existing, there were obvious communal riots but they were regional and pretty small nothing very big. And then the war of 1857 occurred, it is also known as the sepoy munity or the first war of independence depending on who you ask. This was quite a success initially as the army in the north India revolted and the Hindu and Muslim soldiers were united and even declared the Mughal king as the ruler of India and the various other leaders of the war (most were Hindu ) declared their allegiance to the Mughal king for legitimacy .
Then the revolution was routed due to various reasons such as the south and the west being loyal to the British and the naval superiority . Thus the british practice of communal regiments started, before this the regiments consisted of people from single regions of all castes . Now they were split according to castes and the regions were somewhat mixed. This policy was later carried into politics also .
The reasoning behind this was that due to the large hindu majority the muslims would get no recognition the newly formed legislative councils. This was to partly break the protests happening around the partition of Bengal into two different administrative regions. The reasons were partly sound that region was truly too large to be effectively governed but also prevent the any future munity or revolutions.
This was initially opposed by both Hindus and Muslims alike but the Muslim leaders were convinced by the british that since the new East bengal would have a Muslim majority would mean more representation for them, their opposition eventually fell through.
This started the idea for separate communal electorates for the legislative council , this led to the popularisation of the Muslim League. Still the Hindu Muslim communities were fairly cohesive till after the first world war when during the 1930 Muhammad Ali Jinnah delivered a speech proclaiming the Two nation theory of splitting India into Pakistan and India to safeguard the minorities . Initially at the conception of the idea the Nation of pakistan was to be a safe heaven for all minorities ( that changed later) .
Thus at least two countries, the reason that there were not many more countries is because of a number of reasons but mainly the ground work of Gandhi and other leaders leading upto the independence at allaying various grievances of people from various districts and most of the people wanted independence from aristocracy. Lastly just before independence the first home minister of India Sardar Vallabhbhai Patel. He was largely responsible for integrating India into one entity and convincing the various rulers of the princely states to join India. The official line is that they were invited to tea parties and such and were gently persuaded by appealing to their patriotic side, this work for almost all the states except that of Hyderabad. It had to be invaded and annexed. That is another matter all together.
Judith Margaret Brown (1994). Modern India: the origins of an Asian democracy. Oxford U. Press. p. 228.
Gandhi, Rajmohan. Patel: A Life.
Edit: Also Lord Mountbatten helped with the integration of the country by convincing many monarchs to join as he was friend of many and was to become the first Governor General of the country and was related to the British Monarchy thus giving him a lot of credibility in their eyes.