Banks see money come in and out of your account every day. Does it matter how they process those transactions - by taking all the money out before adding incoming money, for example? You bet. Some banks process all the checks you wrote, ATM withdrawals, and online bill payments before processing check deposits, incoming ACH deposits, and so on. They also process the money going out starting with the largest items, such as your mortgage payment.
The result is that you can end up paying more in overdraft charges. What can you do? First, manage your budget so this doesn't affect you. Next, use a less expensive overdraft protection feature if you pay a lot in overdraft fees (such as an overdraft line of credit). Finally, know how your bank processes transactions, and switch to a better one if you're not happy with your bank's policy.
Further reading:

