Your credit card limit is nothing more than a simple number. When you purchase something, the merchant receives a number (i.e. the amount of the transaction) from your card company (e.g. Visa) in their bank account, and that number is subtracted from your limit (added to your balance).
The amount is recorded, and isn't changed, so that's how they get the "exact" amount you paid. Transferring a number is easier than the retailer having to wait for cash to get from you to your card company to them. Moving numbers around is the basis of the modern financial system.
And yes, it is always a risk to let someone else have your credit card number. An untrustworthy company/person may use it to charge you without your permission, or if they have your full details they could use it as if they were you. With a reputable retailer like Amazon, the main risk is data theft: If a security hole is found in Amazon's system, someone could steal your credit card info and misuse it.