These three punctuation marks are very similar and when and how they are used can be confusing. They are not the same.
The hyphen is the smallest in size(-), followed by the N dash (–), which is the size of an N, followed by an M dash, (—) which is the size of an M.
A hyphen doesn't have any spaces around it, and its main function is to connect words together, so it is used in compound adjectives,
A hyphen is often used with numbers,
He invited thirty-two people.
It is mainly used to avoid confusion.
The N dash has two main uses: it is used to express a range, and it is used with prefixes.
Children between the ages 9 – 12 are not allowed to enter. (range)
This is a pre – renaissance painting. (prefixes)
The M dash is most commonly used to give extra information within a sentence.
I spoke to her — I didn't need to — after I spoke to him.
It is also used as a kind of bullet point,
You need to bring the following items
Notice both the N and M dashes have spaces around them, but hyphens don't.
THE PROBLEM WITH EM DASHES
The problem with the dash is that it discourages truly efficient writing, and it disrupts the flow of a sentence. They should be avoided when writing for Cambridge exams.