To prevent people from withdrawing the $2000 from an ATM and stuffing it into their mattresses, the credit card would have to contain a technical barrier against cash withdrawals. This technology already exists: Food stamps haven’t been physical stamps for decades. Today, those in the SNAP program are issued a card that looks like any other credit or debit card, but with restrictions.
The remaining loophole would be through retail returns: People could buy something, e.g. a $2000 TV, and return it for cash, which they could then deposit. The friction of the process, the sheer hassle of it, would make it relatively uncommon, and to prevent problems with cash flow, retailers could also institute no-return/no-refund policies for purchases made with stimulus cards.
This is not a perfect solution, and just as with direct deposits or paper checks, there are bound to be cases of people not receiving their credit card and cases of people receiving more than one. These are costs associated with inaccuracy that the government has been willing to pay in exchange for getting stimulus payments out fast.