Many Chinese dynastic names were drawn from regional titles, corresponding to the ancient kingdoms before unification under the Qin. For example, Yang Jian was the Duke of Sui, a title corresponding to an area in modern Hebei province, before usurping power and becoming the Emperor of Sui. Zhao Kuangyin adopted the title of Song after the place where he held military command.
However, as you hinted at, legitimacy was another reason an emperor might choose a name. Liu Yuan was a sinicized Xiongnu who named his state Han, and claimed to be a descendent of the imperial family of the famous Han dynasty. More famously, Liu Bei of the Three Kingdoms period claimed the same inheritance. Traditionally Chinese historians have appended further qualifiers to repeat dynastic names, so Liu Yuan's state becomes Northern Han based on it's capitol, and Liu Bei's state becomes Shu-Han, as it was centered in the historic territory of Shu. But these are qualifiers added after the fact, both states simply called themselves Han.
But of course, there were imperial dynasties started by people without aristocratic titles and which did not derive from the classical states. These names were often symbolic instead. The usurper Wang Mang formed the short lived Xin dynasty, with Xin meaning "new". When Jurchens invaded northern China they adopted Jin, meaning golden, as they originated from what they called the Golden River. The Mongol Kublai Khan used the name Yuan, meaning fundamental or primary. Zhu Yuanzhang, a peasant leader of the Red Turban Rebellion which overthrew the Mongols, chose the dynastic name Ming, a term meaning wise, or bright.
And yes, romanization might be part of the confusion. Keep in mind that Mandarin has a lot more homophones than English and as a tonal language derives meaning from the way a word is stressed. So two names might seem the same printed in English but actually be different words referring to different entities. For instance, above I referred to the Jin dynasty. That should properly be rendered Jīn, with the mark above the i referring to the a high, flat tone of voice. It is represented by the character 金. There is another Jin dynasty, properly rendered Jìn, with the mark this time referring to a sharp, dropping tone of voice. This is rendered 晉 in writing.
If you want to know more in general about the history of the major dynasties and naming conventions, check out John Keay's China: A History.
If you want to know more about the titles of nobility and how they evolved over time, check out Cambridge's excellent ongoing series on Chinese history.
The answer is all three. And it's best to demonstrate this with some case studies.
The first Jin (晉) state was created around 1100BC as a fiefdom within the Zhou Dynasty. Since it was centered around modern Shanxi and Shaanxi provinces, subsequent polities have also adopted the placename. In 263 AD, Sima Zhao, the regent of Cao Wei and son of Sima Yi, was granted the area and the title of Duke of Jin. From this, he founded the Jin Dynasty, which lasted until 450 AD. The last iteration founded in c.900AD was also based in Shanxi, this time led by an ethnic Shatuo king. Today, it remains the abbreviated name for Shanxi province, i.e. you can see it on their car plates. These are not to be confused with the Jin (金) state in Manchuria, which were Jurchens and the precursors to the Qing Dynasty; or the Jin (辰) state in Korea which was the first to unify the peninsula.
The first Tang (唐) state was actually the first name of the first Jin state, and was named for the capital city of Tang, today Taiyuan. The Tang Dynasty was founded in 626 AD by Li Yuan, who was the governor of Taiyuan, and hence the Duke of Tang. Since the Tang Dynasty was prosperous and powerful, subsequent polities tried to portray themselves as restorers of the Tang. The Jin polity which started in c.900AD hence renamed itself as Tang, lasting another ten years.
The first Wei (魏) state was founded from the partition of the first Jin state in 403 BC. It took its name from its founder Wei Si, who was part of the powerful Wei family, who in turn took their name from the province of Wei, in modern day Hebei province. Oddly enough, only a small part of the province of Wei belonged to the Wei state, the majority of it belonged to a different Wei (衛) state. This Wei (衛) state was originally a vassal of the Zhao state which had also been born from the partition of the Jin state, and was a key rival of the Wei (魏) state. Using the intermarriage between the two Wei states, the Wei (魏) state conquered and vassalised its smaller neighbour around 320BC. Subsequent Wei states have assumed that placename, most prominently the Cao Wei state founded by everyone's favourite bad boy Cao Cao, who was made Duke of Wei in 213AD. For unknown reasons, the ethnically Xianbei Northern Wei Dynasty in 328AD changed its name from Dai to Wei even though it was based in Inner Mongolia. The Wei Emperor was a renowned general, administrator, and poet; much like Cao Cao less than a hundred years before him, and it is thought that he personally wished to emulate his hero.
Then we have the Han (漢) states. The first Han state was the Han Dynasty in 202BC, which has become the transnational ethonym of all Chinese people today. It was named for the city of Hanzhong which it's first ruler Liu Bang had administered, which was named for its position along the Han River. The later ethnically Shatuo state of Han in 947AD also adopted the Liu surname, in an effort to portray itself as ethnically Han Chinese. These should not be confused with the state of Han (韓) which was also founded from the partition of Jin in 403BC. That state of Han should not be confused with another state of Han (韓國) which actually still remains the official name of Korea. The word 韓 meaning "great leader" in Korean and is thought to be related to the Mongol word "khan".
As an extra, we have the Ming (明) Dynasty, which means "light", and was named for a Manichaeist cult. Manichaesm (明教) originated in Persia, and was a dualistic religion emphasising the everlasting battle between light and dark. In China it syncretized with Buddhism to form a secret cult called the Order of the White Lotus (白蓮教) prophesized the coming of a Lord of Light (明王下世) who would liberate China from the Mongol Yuan Dynasty. As the leader of the Order, the Ming Dynasty founder Zhu Yuanzhang sought to cultivate this persona among his followers.