From my knowledge mughal soldiers wore a combination of plate and mail armor and often carried small disc shields with them. Wouldnt the widespread use of gunpowder have made these obsolete? I know that in the 1600s large quantities of muskets were being used in Indian warfare, so why were soldiers, and often cavalry so heavily armored? Did the armor help stop bullets, and if so why didn't contemporary western armies use armour?
They became less armoured over time, similarly to European soldiers. In 16th century art, armour is common. Often, most horses are depicted armoured. While guns - both field artillery and matchlock muskets - were important to Babur's victory at the Battle of Panipat in 1526, he only had about 1200 muskets (for a total force of about 15,000). Since most of the soldiers in the battle used sword, spear, and bow (especially since the enemy who outnumbered Babur lacked cannons and muskets), armour was still useful. Note the armoured horses in these 16th century depictions of Mughal soldiers:
https://commons.wikimedia.org/wiki/File:Vaki%27at-i_Baburi_-The_Battle_of_Panipat(1526)_by_Deo_Gujarati.jpg
https://commons.wikimedia.org/wiki/File:Battle_Scene_from_an_early_17th_century_Shahnama.jpg
But in early 16th century Europe, despite the use of both handguns and gunpowder artillery, we see plentiful use of armour:
1510: https://commons.wikimedia.org/wiki/File:French-gendarme.jpg
c. 1515: https://commons.wikimedia.org/wiki/File:Der_Weisskunig_93_Detail_Gendarme_Charging.jpg
Over the 16th century, in both Europe and India, muskets and cannon became more common, and the use of armour began to decline. For example, in the later 16th century in Europe, we still see armour commonly worn by soldiers, but fewer armoured horses:
Much of the Mughal horse armour that survives dates to the early 16th century:
which suggests that it was used less after that time, which matches artwork showing less horse armour in use, and even a noticeable decline in the wearing of armour by soldiers:
In the 17th century, guns became more common, and armour further declined, with the last fully armoured soldiers largely disappearing from Western Europe in the mid-17th century. However, armour continued in use in Europe: breastplates and helmets continued to be worn. Even this limited armour became less common, falling out of use by infantry and become less common among cavalry. Most cavalry units that retained helmet and breastplate only wore it as part of their ceremonial uniform, although some French units wore them in battle at the start of World War 1:
It is in this time, from the 17th century onwards that we see a difference between India and Europe. Notably, Indian cavalry often retained the bow as a weapon, and would often fight with lance and sword and shield (some cavalry carried muskets in addition to their bows); one important reason for the retention of the bow was the general non-adoption of the pistol as a cavalry weapon. But the use of full armour declined, and 19th century British descriptions rarely report cavalry wearing more than helmet and a mail shirt. Art often shows very little armour (but shields are still fairly common):
Some full armours continued to be made, for both man and beast (elephants as well as horses) for ceremonial/parade use, but guns were common enough on the battlefield that it was of little value in battle. The partial armours that were still worn by some cavalry were useful if they fought other cavalry with sword and spear (or bow).