It makes sense because 12:00am = 00:00 in 24 hour format. It has to switch to AM before 1:00 because every moment after 00:00 is beyond midnight, and thus in the am category. Therefore, it's easier to say that 12:00am is the minute right before 12:01am (00:01) - additionally, the time denoted by 12:00:01 (one second after midnight) must be am by the very definition of the am category, and that second along with 59 more are still in the minute that is 12:00am, or 00:00, hence why that minute is denoted as am as well.