Believe it or not, this is done as a service to you. The reason for this has to do with a fundamental difference between a credit card account and a checking account.
With a credit card account, there is no money in the account; every charge is borrowed money. When you get to your credit limit, your credit transactions will start getting declined, but if the bank does for some reason let one get approved, it's not a big deal for anyone; it just means that you owe a little more than your credit limit. Note that (almost) every credit card transaction today is an electronic transaction.
A checking account, however, has real money in it. When it is gone, it is gone. When a balance inquiry is done, the bank has no way of knowing how many checks you've written that have not been cashed yet. It is a customer's responsibility to know exactly how much money is available to spend.
If you write more checks than you have money for in your account, technically you have committed a crime. Unfortunately, there are too many people now that are not taking the responsibility of calculating their own checking account balance seriously, and bad checks are written all the time. When a bank allows these transactions to be paid even though you don't have enough money in your account, they are preventing a crime from being committed by you. The fee is a finance charge for loaning you the money, but it is also there to encourage you not to spend more than you have.
Even if you use a debit card, it is still tied to a checking account, and the bank doesn't know if you have written enough checks to overdraw your account or not. It is still your responsibility to keep track of your own available balance.
Every time this happens to you, thank the bank as you pay this fee, and then commit to keeping your own running balance and always knowing how much you have left in your account.