On paper it seems like the Mamluk Sultanate should have been well matched against the Ottomans, it was big, rich and had a significant population. They had already fought the Turks to a stalemate just a few decades before, so why do they seem to flop over so quickly in the war from 1516-17? Its not like the Turks were ever able to waltz into Iran in the same kind of way.
Did the adoption of gunpowder among the Turkish forces help much?
I'll try to answer our question, sorry if it doesn't satisfy you
The Mamluk Sultanate at this point was ridden with problems that they couldn't properly face the Ottoman army. First, the Mamluk economy was in a slump and they were short in cash. Mamluk agriculture was seriously depressed, its income decreased considerably from 9 million dinar to 2 million dinar. The monetary system also collapsed, gold and silver coins were replaced by copper coins, which signaled the decline of the economy. Long-distance trade cannot cover the deficit, as the Indian Ocean trade routes were constantly being attacked by Portuguese pirates and that trade doesn't play a big role in Mamluk economy. Total annual Mamluk exports to the northern Mediterranean accounted for less than 2% of their GDP. The iqta system that the Mamluk practiced has also been severely undermined by the practice of many Mamluk nobles to transform iqta lands into religious endowments (waqf), whose income should be to the benefit of the offspring of the founder. Therefore, a considerable portion of land income was controlled by the nobles and their families. The privatization of the land proceeded quickly and at the beginning of the sixteenth century around 40% of the overall cultivable land was already transformed into waqf property, thereby leaving less and less land for the iqta system. There were economic reforms undertaken by Sultan Qaytbay, like how he tried to increase his cash reservoir by getting all unproductive people from the payroll, but to ordinary Mamluks, reform means that his life circumstances and his economical bases were severely threatened and so mostly opposed to reform attempts. Additionally, there had been a general decrease of the population due to recurring plagues which haunted the Mamluk Sultanate since the first outbreak of the Black Death in the middle of the 14th century which further decreased agricultural output and tax incomes.
Second, the Mamluk military isn't quite strong. The Mamluks lacked sufficient manpower, the recruitment of new Mamluks was a difficult task as their import had to be done in parts through enemy territory. Moreover, maintaining Mamluk armies was expensive, without having a direct positive effect on the economy. Therefore, the number of Mamluks depended on the economic situation of the Sultanate, which since it was in a slump, the Sultanate can't maintain a high number of Mamluks at their disposal. The number of Mamluks decreased from 12,000 in the middle of the 14th century to 6000 at the end of the 15th century. To exacerbate problems, many freshly imported Mamluks died of the plague as they were living close together in barracks. Contrary to popular belief, the Mamluk Sultan did recognize the value of firearms and did equip at least some of their armies with firearms, but was still comparatively few in numbers that the Ottoman army were still able to outgun them. This was caused seemingly not by the reluctance of the Mamluk soldiers to fight with firearms, but the incapability of the Mamluk Sultans to obtain a sufficient number of them or to produce them on their own. What rendered things even complicated for the Mamluks was that they had to import the key raw materials for cannons and firearms like copper, saltpetre, sulphur, timber, and iron from Europe or from the Ottomans. It would have been a herculean task to overcome the inequality of resource distribution in comparison to the Ottomans. The Ottomans had therefore far more guns at their disposal and another decisive factor is that they outnumbered the Mamluks on the battlefield, thanks to their superior bureaucracy and military logistics. The latter was especially important since according to historians like Albrecht Fuess, the Mamluks might have possessed a considerable amount of firearms, but the Mamluks decided not to bring them in large number simply because they lacked the infrastructure, men and horsepower for the transport of large numbers of mobile field artillery. Additionally, the Ottomans with their tabur cengi wagons give considerable tactical advantage over the Mamluk armies. Furthermore, the lack of a considerable Mamluk navy also eased the Ottoman conquest of Egypt, since the Ottoman advance on Egypt was easily supported through naval assistance and Ottoman convoys carrying troops and provisions was unhampered.
Finally, the Mamluks suffered from internal fractional rivalries and political difficulties. For example, tensions between Qaranisa and Julban Mamluk clans play a vital role in the defeat of Marj Dabiq, as the Qaranisa were angry by the fact that the Sultan held the Julban back at first and restrained them from engaging in the fight, therefore the Qaranisa apparently slowed down their own efforts considerably. Much of the energy of the Mamluk Sultanate was taken up by such rivalries. These developments might also explain why a considerable part of the Mamluks deserted at the battle of Marj Dabiq and defected with the Mamluk governor of Aleppo to the Ottomans. Additionally, the Mamluks doesn’t get any love from the population of Syria and Levant either, since the Mamluk Sultans always considered Egypt as center of their Sultanate and the Levant as only a buffer zone. So the local population looked on indifferently as the remnants of the Mamluk army retreated towards Egypt. Additonally, many historians recently also proposed the “age factor” as another reason on the Sultanate’s quick downfall. Mamluk Sultans usually had a long career in various functions in the army before obtaining the supreme post of Sultan. The Sultans of the 16th century were on average around 70 years old when they climbed up to the throne. The age structure and the vulnerability to disease among the members of the high command in the late Mamluk Sultanate meant that the Sultan was usually old and weak. In any cases, the will for major changes and reforms was weakly developed since it had taken such a long time to climb the career ladder as a brave servant of the system. Once at the top, there was little incentive to question the complete structure of the Sultanate with the exceptions of some Sultans like Qaytbay. This also explains why the Sultan during the Ottoman conquest, Qansuh al-Ghawri died from stroke due to excitement at the decisive battle at Marj Dabiq. He was in his 70s and assailed by debilitating pain of eye disease.
Sources:
The Mamluk Sultanate from the Perspective of Regional and World History edited by Reuven Amitai and Stephan Conermann
Egyptian Society Under Ottoman Rule 1517–1798 by Michael Winter
The Arabs of the Ottoman Empire, 1516–1918 by Bruce Masters
The Cambridge History of Egypt: Islamic Egypt, 640-1517 edited by Carl F. Petry