Banks want to encourage non-branch banking, i.e. use of ATM machines, telephone banking, and online banking. It considerably reduces their costs if less people walk into branches, as they need to have fewer branches with fewer staff.
Credit Card companies make billions in commissions from card transactions, both in shops and over the phone or online, and are therefore very keen to ensure that customers feel confident in using their credit cards.
For this reasons both banks and Credit Card companies will as a general rule refund moneys lost due to card or online fraud. The amount they pay-out is marginal compared to the amount they stand to loose if people were worried about fraud and went back to using notes and walking into branches.
The exceptions are cases were there is obvious negligence on the customer’s behalf, e.g. when a code is written down on a piece of paper in your wallet. But this is a multi-billion industry and the banks prefer that you keep spending even if they have to mop-up after the fraudsters.
This also explains why the banks are so keen on card security – they are not really concerned about your money, what they are concerned about is that you might use your card or online banking less. Also since they will in most cases refund the money lost due to card fraud, they are actually protecting their own money by trying to fight card fraud, not your money…