AM is a shortened acronym for anti-meridian which is the 180 degree meridian. The time the sun crosses this is the point of midnight universal time and basically means hours from this point until the sun crosses the opposite meridian, zero degrees, at noon.
Post meridian (PM) meaning after, is the opposite. The time the sun crosses and after zero degree parallel or after noon.
Anti-meridian meaning before the sun crosses the zero degree meridian.
We split the 24 hours into time zones so the AP/PM is associated with your local time, One could just as effectively use 24 hour format and coordinated universal time, the AM/PM would still mean the same.
IE: Where I live, it is presently 1:57 PM, mountain daylight time,,exactly the same as 20:57 PM universal time.