Accounting can be a little counterintuitive. It’s important that the accounts sum to zero, but the question of how credits and debits are assigned to a transaction can be a little obscure. For instance, if you’re purchasing a long-term asset, you:
- debit your asset account
- credit your bank account
and if you’re depreciating an asset, you:
- debit your depreciation expense account
- credit your accumulated depreciation/contra asset account
in other words, as you accumulate cash, or assets, or expenses, you debit the accounts tracking those things. As you accumulate liabilities or income, you credit the accounts tracking those things.
The key is that, contrary to what you might expect, “credit” means “to take away from”, and “debit” means “to add to” (well, sort of, to a first approximation, for asset and expense accounts, at any rate). Wikipedia has a passable explanation.