How was the situation different in a way that allowed such a large sultanate to be completely annexed by the Ottomans, when they had defeated them on land just two decades before?
Well, we have to take in mind some things, the Mamluks had at first a hard time with some early victories both land and sea by the Ottomans in 1485, but after the battle of Adana in the same year, the Mamluks would have the upper-hand, and the Ottomans, from 1485 to 1488, would go from a fiasco to another, plus, the Ottomans were facing some revolts during those years. In 1488 the Ottomans would attempt to end it all with a full-scale attack but failed. In 1490 the Mamluks would be on the offensive and the following year the Ottomans would offer a stalemate. The following years the Mamluks would be the indiscutible mayor power of the Middle East, but with the portuguese starting alternative trade routes into the indian ocean, the Mamluk's trade routes were in jeprody after some of their merchant ships were attacked and sacked by the portuguese, so they declared war against Portugal, starting the Mamluk-Portuguese war (1505-1517), despite counting with the support of the Venetians and Ottomans, the Mamluks didn't have a lot of naval experience nor had a big navy, which ended up in a completly one-sided war dominated by Portugal, this resulted that the trade from the indian ocean for the Mamluks, one of their most important sources of income, would be completly cut off, leaving the Mamluks on an extremly soft-spot, and with the Ottomans after finishing winning a war against the persians and having complete control of their armies and high morale after a successful war, they invaded a Mamluk sultanate with an economy and spirit broken.