A card payment is two separate events. The first reserves the money, the second takes it. Almost every confusing line on a statement sits in the gap between them.
When a card is used, the merchant first asks your bank whether the amount is available and whether the transaction looks acceptable. That request is the authorisation. If it succeeds, the bank sets the amount aside and your available balance drops, but no money has left the account.
The second event happens later, often the same night and sometimes days afterwards. The merchant submits the transaction for clearing and settlement, and the funds actually move. A line marked pending is one where the first event has happened and the second has not.
In some trades the authorisation is deliberately an estimate, because the final figure is not known at the moment the card is presented: a fuel pump before you have dispensed anything, a restaurant before a tip is added, a hotel or car hire counter covering possible extra charges. The reserved amount is called an authorisation hold, described in Wikipedia's article on authorisation holds.
When the real figure arrives, it replaces the estimate. As an illustration only, a pump might reserve a round sum before you start and settle for a fraction of it; the numbers and the policy differ by merchant and by country, so a hold you have seen once is not a standard you can rely on.
An authorisation that is never claimed expires on its own. How long that takes depends on the card scheme's rules and the kind of business, and it is normally longer for the estimate-based trades above than for an ordinary shop purchase. Until it either settles or expires, the money is unavailable to you while also not having been spent.
If an order is cancelled before settlement, the cleanest outcome is a voided authorisation: the line disappears and the balance is restored. Where a merchant cannot or does not void it, the hold simply sits there until it times out.
A failed payment that you immediately retry can leave more than one authorisation behind, because each attempt is its own request. The attempts that did not complete expire unclaimed. The same thing happens around the extra verification step that a bank sometimes inserts during online checkout, the mechanism behind Wikipedia's article on 3-D Secure: abandoning that step can still leave a reservation on the account.
Once a transaction has settled, reversing it means sending a separate credit back through the same networks. That credit has its own processing time and appears as its own line rather than deleting the original. It is also why a refund owed to a card that has since expired or been replaced is routed by the bank to the same account, instead of the merchant simply cancelling the old charge.
A chargeback is the formal reversal a cardholder can ask their own bank to pursue, and it has deadlines and evidence requirements. See Wikipedia's article on chargebacks. In practice it is a later step: a pending line usually cannot be disputed because nothing has been taken yet, and contacting the merchant first both resolves most cases faster and is what the bank will ask whether you did.