Every day of your life is split into 24 hour-long increments. Each of these hours can be counted, from the first one (hour 0) to the last one (hour 23).
The 24-hour clock simply counts how many hours have been completed that day. Although it is widely used in Britain, the U.S. military, and various places around the world, North Americans and Australians are far more accustomed to its simpler 12-hour cousin.
The 12-hour clock pivots at 12:00 noon, around the time the sun is at its highest point in the sky. According to the 12-hour clock, everything in the day is either before noon (the morning), or after noon (cleverly named the afternoon).
By splitting the 24-hour clock in half, you are doing two counts: how many hours have elapsed before noon, and then how many hours have passed after noon.
In order to differentiate between these two 12-hour counts, we use the abbreviations a.m. and p.m. You might think that b.n. (before noon) and a.n. (after noon) would make more sense, but 17th-century Englishmen opted to use Latin instead.
In Latin, a.m. stands for "ante meridian." Translated, this means "before midday." The counterpart, p.m., stands for "post meridian," which, you guessed it, translates to "after midday."
To further clarify, it was decided that 00:00, the start of the new day, would be known as 12:00 a.m., or midnight. And 12:00, high noon, would be known as 12:00 p.m. — though, to avoid confusion, many prefer to stick with just "midnight" or "noon."