Translation:The width is exactly two centimeters.
The "de" is required when comparing quantities (more, less, equal, is exactly etc) of nouns, "centimètres" in this case.
It is similar to the requirement for "de" in sentences like "J'ai plus d'argent que toi". The literal translation would be "I have more of money than you".
Note that the "de" is not required in "La largeur mesure deux centimètres" because there is no comparison involved.
Note that the "de" is also NOT used with comparisons of: - adverbs ("Je parle plus lentement que toi") - adjectives ("Je suis plus grand que toi") - verbs ("Je travaille plus que toi")
Hope this helps