It is not really correct to say that Alexander the Great's armies were defeated in India. Instead, it is more correct to say that the army rebelled against Alexander and his ambitions and forced him to withdraw from India.
Alexander's armies won their battles in India. However, after a certain point, his armies and his generals decided they had had enough. They had been out campaigning for too long and they were too far from home. The weather was bad (monsoons) and they were worried about what opposition they might face if they did as Alexander wanted and went to fight the kingdom of Magadha in the Ganges Valley. For these reasons, they resisted Alexander's desire to push on. Alexander finally agreed and the army withdrew from India.