Accounts payable are amounts a company owes because it purchased goods or services on credit from a supplier or vendor. Accounts receivable are amounts a company has a right to collect because it sold goods or services on credit to a customer. Accounts payable are liabilities. Accounts receivable are assets.
Let's assume that Company A sells merchandise to Company B on credit. (Perhaps the invoice states that the amount is due in 30 days.) Company A will record a sale and will also record an account receivable. Company B will record the purchase (perhaps as inventory) and will also record an account payable.
Our example reminds me of an old saying, "There are two sides to every transaction." In accounting we also expect symmetry: Company A has a sale and a receivable, Company B has a purchase and a payable.