At the time of Indian independence, all territories administered by the British were to become either part of India or Pakistan. The 'independant' Princely states were given the additional option of remaining independent. The decisions in case of these states would solely be taken by the respective rulers, not the population.
The Raja of Kashmir opted to stay independent, having visions of creating a Switzerland in the sub-continent. When Pakistan invaded, he agreed to join India, in return for military aid.
A counter argument is that the Indian military took over some princely states that opted to remain free. This was because these states were all entirely within the borders of India, and having numerous 'holes' in the map was ludicrous. In addition, many of these rulers, being Muslim, had initially wanted to join Pakistan, and Jinnah had demanded that corridors be built, crisscrossing the map of India, to join these states to each other and to Pakistan.