How did Islam reach India?

Muslim traders reached India in the 7th century. The first mosque in India was built in 629 AD (when the prophet Muhammad was still alive) in Kodungallur, Kerala.

Muslim armies did not reach (what is now) Pakistan until the 8th century. Muslim armies would not reach (what is now) India until the 10th century, when Mahmud of Ghazni added Punjab to his empire.