Both characters mean
night, also when they are together, when is it better to use each character ?
Beautiful night: 美丽的夜 can be rephrased to 美丽的晚 ?
Good night: 晚安 to 夜安 ?
Originally, 晚 could be written as 莫 (in ancient form): 艹（草, grass）+ 日 (sun), referring to when the sun is below the grass -- sunset.
In modern Chinese, we can understand or memorize it in this way: 日 (sun) + 免 (cancel), without the sun, sunset.
Then its meaning extends to night and evening. So 晚 does mean night and evening, and they are its original meanings!
Originally, 夜 could be written as 亱 (in ancient form): house (dot + horizontal) people (人, Throw away + vertical) + day (旦), referring to (people, sun) stop and rest. It means the time period from dusk till dawn.
Just as 晚，its meaning extends to night and evening.
晚 is more focused on "being late" (at night or in the evening), which is later used as "late". 夜 is more focused on "dark and dusk" (at night or in the evening).
Therefore, “夜晚” can be understood in 2 ways:
(1) in Modern Chinese, night or evening, together as a noun;
(2) as noun+adj: the night/evening is late → the time at night is late.
晚 itself means late, and it doesn't mean night, like 晚霞.
While 夜晚， 晚上，晚间 mean night.
So "beautiful night" is 美丽的夜 or 美丽的夜晚，not 美丽的晚。
However in some words the character 晚 does mean night, that is because it is kind of abbreviation, like 晚安, 晚饭, 晚会。
In regard to when to use 晚 and when to use 夜, there is no hard rule for that. There is no scientific explanation for why one is chosen over another.