Why did ancient emperors like Chang 'an and Luoyang as their capitals?

Luoyang:

One place in our country has always been the first choice for the emperor to build the capital, and that is Luoyang. If China has the most dynasties with its capital, Luoyang is the first place to take responsibility. In fact, why Luoyang is the most capital place for the emperor is mainly because Luoyang is located in the center of our country, far away from the border areas, because wars will occur from time to time in the border areas, and the situation is relatively complicated. Moreover, the geographical location of Luoyang is easy to defend but difficult to attack. If you want to attack, you must first pass through the surrounding cities, but the emperors of the surrounding cities are often heavily guarded and defended at all levels. Therefore, Luoyang was the first choice for emperors to build their capitals, so it became one of the famous ancient capitals in China.

Chang 'an:

1. The terrain around Chang 'an is very dangerous. As long as the surrounding forts are well controlled, it is easy to defend but difficult to attack;

2. Chang 'an District has a good geographical environment; (Now it belongs to over-exploitation, so the Yellow River is seriously flooded. )

3. Since Qin Dynasty, it has been a political center;

4. Closer to the hinterland of the Central Plains, easy to control.