Every accounting entry has one side posted to the P&L and the other to the Balance Sheet (unless you're reclassifying between accounts but that's for another time). In the P&L a debit entry indicates a cost to you, and a credit indicates income earned. In the balance sheet, a debit will increase an asset or decrease a liability, vice versa for a credit.
To record a purchase in your books you have to post one side to the P&L and the other to the balance sheet. Because of the rules mentioned above you debit an expense, and because you need to balance out the entry, you post the credit to cash, which conveniently decreases your cash account asset.
It's confusing at first but easier when you understand and accept the mnemonic DEADCLIC.