Although they might have lost $2K on cupcakes, but the amount of money they would have made by attracting customers on credit is huge.
So generally offering things on credit is like bait to catch customers, there is risk I agree. But profits from such schemes vastly exceed losses, to make them almost negligible.
Lets say you own a bakery, you sell cupcakes on credit. Say you sell $40K worth cupcakes an year to a company. There are chances that you may go under a loss of $2K if the company folds. Will you go for it, or do not offer any credit and lose $40K worth cupcake businesses to somebody else?