Logic of the word 上午 (shànɡwǔ, morning) 上午 apparently means "morning". But I don't understand the logic of this word for two reasons:

1) Isn't the meaning of 午 "noon"?
2) With the words 早上 (early morning) and 晚上 (evening) then 上 is the second character, while in 上午 it is the second character, which always confuses me

What is the logic of the above observations?

Is there any "trick" to remember these words better?

Thanks!
上午, 下午 has the same logic as 上週, 下週. 上 is a prefix meaning previous, before, and 上午 means before noon.
If you must assign a meaning to 上 in 早上 and 晚上, I would interpret it to be a suffix meaning at, during, in, or within. 早上/晚上 means during or in the morning/evening.

用在名詞後。表示一定的處所或範圍。(Used after a noun, indicating a specific location or [within a specific] range.)

《孟子・梁惠王上》：＂王坐於堂上，有牽牛而過堂下者，王見之曰：＇牛何之？＇＂
《戰國策・秦策一》：＂人生世上，勢位富貴， 蓋可忽乎哉！＂
《醒世恒言・三孝廉讓產立高名》：＂有一人姓許名武，字長文，十五歲上，父母雙亡。＂
巴金　《探索集・懷念老舍同志》：＂在他們的心上、在他們的筆下，他至今仍然活着。＂