Because credit cards give you more protection should your card number be stolen.
Most credit card companies have a limit on how much your account may be charged in the event of false charges. In fact, many companies won’t hold you responsible for any charges should your account number get hacked. That’s not true with your debit card. Thieves could also use that to hack into your bank account online and make off with whatever you many have in your savings or money market accounts if those are linked to your checking account.
To be on the safe side, always pay with a credit card, then reimburse that card as soon as possible.