An interesting question.
Proximity played a major role. The regions in the NW of the map were close to Muslim predominant regions of Afghanistan & Iran hence the majority. Once the Mughal rule faded away in late 1700's the reassertion of locals who had till them been suppressed & resented Muslim rule began. Actions by Marathas in 1800's punctured the balloon of invincibility of the Muslims to locals leading to greater re assertion of the religion of the land.
Muslims who had shifted inland from the west and those who had converted remained in the land they occupied , they are shown in the lighter shades of green. Hindus / Sikhs began to gain predominance once again.
By 1900 when this map was made the British had taken control completely , they relied on Princely states to exercise control over large areas & directly governed the rest. In both cases forceful conversion did not take place anymore.
This was a period when communication &infrastructure was not well developed hence migration of people for commercial reasons had not begun. The original demographic pattern by & large remained.
Next, it is worth remembering that Mughals even at their height of power relied upon local Hindu kings who secured their kingdoms through allegiance to the seat of Agra / Delhi. In so doing they retained their personal Hindu identity & protected the religion of those whom they ruled..
In the Punjab , the beginning of 1800 saw huge Sikh resurgence . The boot soon shifted to the other foot and remained that way for the next 50 years or so. Muslims never got to rule that region again.
These and more facts could help in answering the question posed in the title.
Was this necessary ? How is it connected to the topic ?
Its not like that Muslims are all one happy family. Shia & Sunnis have never got along. The Ahmediyas, Bohras & so many other sub sects are struggling to be even accepted as Muslims .
We all have issues so lets not interject for the sake of posting something .