People overlook the way how most feudal armies were made up. For example when the King is gathering an army, he asks his Sardars/Nawabs/subject rulers to provide him with a certain number of troops.
It is quite expensive to have fully armed & trained army on a permanent basis and a local war lord may only have a few hundred professional soldiers. At the time of gathering a ‘Lashkar’ for the king, many untrained, poorly armed young peasants are rounded up and forced to join. What this means is that in an army of 100,000; number of professional soldiers may be only as low as 10 to 20 thousand. On the other hand invasion force is normally composed of hardened fighters. Therefore the numerical superiority does not translate into superior fighting capability. Besides, most of draftees are not battle hardened and would run away when the going gets really tough.
Skill of the commander is another factor, Babur was a veteran of hundreds of battles, most of which he lost but he gained experience. Ahmed Shah learnt his leadership skill under Nader Shah Afshar, known as Napolean of the Middle East. Ahmad Shah had also tasted his share of losses. For example he was defeated by the Moghul Army at Manupur (Sirhind) in March 1748 mainly because he lacked artillery.
Marathas had good commanders in 1761, but Ahmad Shah was better and he made better use of his mobile artillery. The battle actually lasted several days and the pitched battle only started after Ahmad Shah’s forces had weakened Maratha flanks.