Historically, the British integrated their holdings in India into the British Raj. Sri Lanka and Myanmar were also part of the British Empire in India. Sri Lanka is moreover culturally similar to India. Then why were these countries separated from British India?
Neither of them were really part of India to begin with.
Sri Lanka was formerly the British Crown Colony of Ceylon, which grew out of an earlier Dutch colony. In 1795, during the Napoleonic Wars, Britain took over control of Sri Lanka's coastlines from the Dutch Republic. The British East India Company was entrusted to administer the area, but it was generally a failure amid revolts and non-cooperation by locals. In 1798, the Lord North was installed as governor to represent the Crown's interests.
When the British Army took control of the interior of Ceylon in 1815 under the Kandyan Convention, the island became a new Crown colony. It was therefore never part of the later British Raj created in 1858. So the real question isn't so much why Sri Lanka separated, but rather why didn't Ceylon merge into the Company Raj in India.
And the answer is, they simply didn't have that much in common. The native Sinhalese majority of Ceylon is primarily Theravada Bhuddists who speak an Indo-Aryan language. The Company's Madras Presidency on the other side of the Palk Strait, in contrast, was primarily populated by Dravidian speaking Hindus.
Ultimately, Sri Lanka was only part of "British India" in the sense that it was briefly administered by the East India Company. Its acquisition was a project of the British Crown, by British forces, and through British representatives. Its political ties to the Company was limited and ephemeral - an arrangement of convenience for a minor territory while Britain was preoccupied with France.
Administration of Myanmar was detached from India in 1937, when the Burma Office was created. It went on to govern Burma independently of India and the Indian Office, giving effect to the provisions of the Government of India Act 1935.
Unlike Sri Lanka, Myanmar was fully a part of British India. However, prior to coming under the control of British imperialism over the course of three wars, Burma was its own distinct country. It was, and is, culturally, linguistically and ethnically separate from India. Moreover, it was also a huge territory. All these factors made administration difficult.
We have not included Burma in our survey except in so far as, while that province remains part of the Indian polity, as for military reasons it must, it is necessary to provide iai its representation in the central Government. Our reasons are that Burma is not India. Its people belong to another race in another stage of political development, and its problems are altogether different. For instance, the application to Burma of the general principles of throwing open the public service more widely to Indians would only mean the replacement of one alien bureaucracy by another.
- Montagu, Edwin Samuel, and Frederic John Napier Thesiger Chelmsford. Report on Indian constitutional reforms. HM Stationery Office, 1918.
Under British rule, large numbers of Indians migrated into Burma. This, and being administered as a division of the general Indian government, led to strong resentment on the part of the Burmese. With the rise of nationalism exacerbating tensions, the natural division of Burma/India probably seemed like a good idea for improving administration of the two countries.