AM and PM stands for Anti Meridiem and Post Meridiem. Both are Latin words used to represent Before Noon and After Noon. The words AM and PM are used in 12-hour clock system.
Literally Anti Meridiem means "before midday"" and Post Meridiem means "after midday". The 12-hour clock system divides 24-hours clock system in two periods and specifies it in AM and PM. One period which could be tracked by the position of the Sun (day) followed by another period which could be tracked by the Moon and stars (night).
The 12-hour clock system may be confusing without AM and PM. For example: If I say that I will meet you at 6 O'clock so it may be confusing that it is 6 O'clock morning or 6 O'clock evening. Thus, to remove this confusion, AM and Pm is used in 12-hour clock system
Although Indian Railways follow 24-hour clock system, most of the watches and clocks follow the 12-hour clock system.
AM: AM is used to specify time from midnight to noon. (12:00 AM to 11:59 AM). For example: If I say that I have to go office at 9 AM, it means 9 O'clock in the morning.
PM: PM is used to specify time from noon to just before midnight. (12 PM to 11:59 PM). For example: If I say that I will meet you at 9 PM, it means 9 O'clock in the night.