AM stands for ante meridiem, which is Latin for "before midday." PM stands for post meridiem, meaning "after midday." Together they split the 24-hour day into two halves so a 12-hour clock face can cover the entire day without confusion.
Midnight is 12:00 AM — the very start of a new day. Noon is 12:00 PM. Everything from 12:01 AM through 11:59 AM falls in the morning hours, and 12:01 PM through 11:59 PM covers afternoon and evening. The switchover catches people out because 12:00 itself belongs to the "other" label: noon is PM, not AM.
Most of the world runs on a 24-hour clock — what Americans sometimes call "military time." In that system there is no ambiguity: 14:30 is always 2:30 in the afternoon. But in everyday conversation across the US, UK, Canada, Australia, and parts of Latin America, the 12-hour format dominates. Context usually fills in the gap ("meet at 8" clearly means 8 AM for a work meeting, 8 PM for dinner), yet for travel bookings, medical appointments, and anything automated, mixing them up can be costly.
A quick trick if you need to convert on the fly: for any PM time, add 12 to the hour. 3:45 PM = 15:45. For AM, the number stays the same, except midnight: 12:30 AM = 00:30. Going the other way, subtract 12 from any hour above 12 and slap PM on it.