In the Middle Ages, nobles did not use numerals, even if some sovereigns did. The numbers by which they are known nowadays were created by Early modern historians. While doing so, they adopted the rules of their own times. These rules are a result of the early modern noble titles regulation.
In Britain, the titles were both personal (only one holder at a time) and severely controlled by the King (no one could simply assume being an earl or viscount), same goes in Spain or Italy, so the rule is "X, Nth Duke of Y". The thing are complicated further by the different creations of the same title, as ShortsBelfast wrote ; in fact, despite this legality, noblemen usually style themselves with a higher numeral than the legal one, because they saw two creations in the same family as one, or they did not take into account attainders. For the Middle Ages titles, it is not even possible to know if a title was re-created (thus starting a new series of lords) or a female-line succession accepted. In France, titles were personal but not severely controlled by the King ; Dukedoms were the only truly regulated title, but any noble could assume being a marquis without being prosecuted. In Germanic areas, titles were not personal, so no one could be The Duke of Z, much less the Nth Duke of Z. In both countries, numerals, when used (very few did in France), are on the "x IV, Duke of Y" model.
An alternate naming system is using numerals not for title succession, but for family succession. This is usually done for Italian families, which had a rich history even before being granted titles.