I've been reading asoiaf lately and I noticed that everyone beneath the king is a lord. To my understanding no other titles seem to exist in Westeros and people are just higher or lesser lords in comparison to their lieges and vassals. In contrast, to my knowledge, medieval Europe had dukes, counts, barons and all sorts of titles for people (and land, county vs duchy etc). Why wasn't everyone just a "lord"? Why did the differentiation between different types of lords/lands exist and where did they originate from? What made someone a duke and not a count or king?
Additional question, was the land named after a title or the other way around? If a count becomes a duke for reason or another, does his county become a duchy or is he just a duke who owns a county?
Among the aristocracy there is and was a hierarchy and the precise titles depended on where and when you were a noble. For example prior to Edward III there weren’t Dukes in England, they were a title used commonly in the Holy Roman Empire but are most closely linked with France, where the power and land of the King was often dwarfed by his vassals’.
Dukes were among the most powerful of nobles below Kings and Emperors and it wasn’t uncommon to find independent Dukes. Brittany, Lithuania, Ferrara and Lombardy/Milan are examples. The title is derived from the Latin “Dux” meaning “Leader” and was originally a hangover from Roman times where Roman-allied Germans and other peoples would appoint a Dux as governor of a region. If it helps you could think of The Reach from asoiaf as a comparison as France is where GRRM based it on. The Hightowers, for instance, occupy a position not unlike a Duke of Aquitaine with its vast land, developed ports and economic significance.
Next up you have a Marquess. These days the name has mostly lost its meaning but it originally referred to those lords whose lands were on borders, known as “marches”. These were historically significant for their roles in commerce and warfare. They are traditionally above Earls and Counts but below Dukes. There is an ASOIAF version with the Marcher Lords, I think the Dondarrions and Selmys? If that helps
As I mentioned, England didn’t have Dukes prior to 1337, instead they had earls. Unlike the Latin Dux, Earl is derived from Jarl (like in Skyrim) and is a leftover in the old English Eorl (added correction). They varied in power, some could be exceedingly wealthy and powerful and others not. The Scottish equivalent at the time would be Thane.
Count, like Duke, is from Latin, namely “comes” meaning companion. Today and for most of history these are mostly considered equivalent to earls though in the earlier Middle Ages an English Earl would likely have more sway and influence with his King than a French count due to being the uppermost tier prior to the formation of marquess and duke.
Viscount can be thought of literally as vice-count (but don’t pronounce it that way) they were below earls and counts but still nobles. They occupied a position in society that would later be replaced by commoners as bailiffs and bureaucrats. They didn’t wield significant influence or lands and were more notable for their use as a prestige title that was above baron. Beginning with John Beaumont during the war of the roses it was used as an hereditary peerage and it was common for former Prime Ministers to receive as a title in later times.
Finally we have Barons, as my answer focuses primarily on English titles since that’s where my knowledge is based. The title is derived from a Late Latin word translated as warrior or mercenary. They made up the bulk of the English aristocracy early on and were a vital part in the creation of any army. While not all of the rebellious subjects fighting the Baron’s Revolts were Barons, many were and it was fought to help expand their rights and privileges. They played a significant role in the creation of Parliament (which I have written about previously) though they would become less significant as it became more commonly an honorary title to be purchased, with no direct relationship to land holdings. Reforms made between the 15th and 17th centuries completely removed powers barons had and made them cease to be important players in politics, beyond their own independent wealth and talents.
As you can see there was quite a lot more variety of titles just in England than in ASOIAF which has only 3 versions of "lords" and a king to my knowledge. I haven’t gone over Kings or Emperors but can do if you’re interested. The reasons for different titles were many. Sometimes it was just linguistic, other times it was about function and sometimes it was about rank.
Hope this was enough information for you:)
As for the names of duchies and counties, they could share names or have different names. For example while there was a Count of Poitiers/Poitou there was no Duchy of Poitiers/Poitou. The title generally went with Duchy of Aquitaine as they were held in Personal Union for centuries.
On the other hand there were both Counts and Dukes of Valois and Orleans. Likewise there were Earls and later Dukes of York. Some places never became associated with Duchies and some did
A count would become a Duke by being given a Duchy, he may also hold a separate county though. For example William VIII of Aquitaine was the Duke of Gascogne, The Duke of Aquitaine and the Count of Poitiers