They represent two distict payment processing mechanisms that just happen to be available on one product. Rather like having dvi and hdmi on you laptop.
Your account number and sort code relates to the bank account.
Your long number, expiry and ccv relate to the card.
It is perfectly possible and not uncommon to have two different cards on the same account, which would have their own card numbers etc.
The BACS, CHAPS, DirectDebit and FasterPayments systems use the account numbers. These transactions are practically irreversible and work through the interbank transfer system and should be considered 'direct money transfers' - electronic cash.
The long digits are used by Mastercard, Visa, AmEx etc and go through their own payment systems. These payments are 'indirect' and may or may not be reversible as the private payment network (visa etc) has some accountability. They work like electronic cheques. This is why debit card transactions can cause you to go overdrawn - you are writing a promise to pay from an account. It is up to the bank to block the card if you have no money, vs a CHAPS payment that checks the money is there before moving it. It is easier (but still hard) to recover money lost through Visa fraud than BACS.
Credit cards have only the long number etc. While savings accounts (non-checking accounts) have only account numbers.
Depending on where you are different laws will likely cover debit card vs money transfer payments. In the UK Direct debit guarantee is the most common protection on the BACS system, while standing orders and faster payments give you little legal power. Debit cards will give you some protection because the payment system stands between you and the bank account, so if you didn't make the transaction you should be able to reclaim the money ('card not present fraud'). If you did make the transaction but the vendor failed to supply or goods were faulty then a Chargeback system exists where you may also be able to reclaim. A bank transfer you make is irrecoverable and refund can only be claimed through court for faulty goods.