Can they? Yes. The mechanism exists.

Is it legal? Depends on the fine-print when the deposit was being made. What did you agree on.

If, after the fine print, the company had no legal right to take the payment on a card that was provided for deposit, then needless to say, you have a case whereby the charge can be reversed.

In most cases, companies, don’t just unilaterally take a payment, knowing well that it could be reversed. Chances are, there is a provision for it somewhere.