Invaders from the Khorasan area (or at least taking that route) carving out kingdoms in northern India seems a recurring theme in Indian history. Indo-Greeks, Indo-Scythians, Yuezhi, Delhi Sultanate, Mughals, Alexander, Nadir Shah, and I'm probably missing some. I have no idea why, mind you - this area isn't my specialty (maybe cavalry strength, as mentioned upthread?) - but if it keeps happening and virtually always in this direction, not in reverse, I'm guessing there's some cause.
So I think that while Muslim conquest of parts of northern India could be delayed by one strong state or another, to stop it outright I'd assume you'd need to prevent the people of the regions which keep conquering India from adopting Islam.