Your keyboard has one horizontal line on it and typography has four. They are not interchangeable, the rules are simple, and the reason anyone learns them is usually that a document came back with them corrected.
The three, and what each is for
Hyphen (-, U+002D). Joins words into one idea: well-known, state-of-the-art, twenty-one. It also breaks a word across a line in typeset text. It is the only one on your keyboard.
En dash (–, U+2013). Spans a range or links two things that remain two things: 1914–18, pages 40–52, the Paris–Berlin train, the Bose–Einstein condensate. If you could say to or and or versus, it is an en dash.
Em dash (—, U+2014). Interrupts a sentence — like this — doing the work of brackets, a colon or a pair of commas depending on where it sits. It is the most versatile mark in English punctuation and the reason it is used so much.
Minus (−, U+2212). Not a dash at all. It is designed to match the width and height of digits so that −5 aligns properly in a column of numbers. Use it in typeset mathematics; use the ordinary hyphen everywhere else, and always in code.
The names come from metal type, where an em was the width of the type body — roughly a capital M — and an en was half of it. The proportions survived the technology.
The accusation
Since language models became common writing assistants, the em dash has acquired a second life as supposed evidence. Text containing them gets flagged as machine-written, occasionally by teachers and editors who mean it seriously.
The observation underneath it is real: models do produce em dashes at a higher rate than the average person, because they learnt from edited prose and edited prose uses them. If someone's writing suddenly acquires them where it never had them, that is a change worth noticing.
What it is not is a test. Em dashes have been standard punctuation for centuries. Anyone who reads books writes with them. Word and Google Docs insert them automatically when you type two hyphens, so a great deal of human text contains em dashes its author never chose. Using the character as proof convicts precisely the people who punctuate most carefully, which is a poor outcome for a rule meant to reward care.
If you want to remove them from something for this reason, that is a decision about your reader rather than about correctness, and find and replace will do it in one pass. Replacing an em dash with a comma usually reads better than replacing it with a hyphen.
Spacing
American convention closes the em dash up against the words on both sides—like this. British convention prefers a spaced en dash – like this – for the same job.
Both are internally consistent and neither is wrong. What reads as an error is mixing them, which happens constantly in documents assembled from several sources.
En dashes in ranges are always closed up: 1914–18, never 1914 – 18.
How they get into your text without you
Word, Google Docs and most editors convert two hyphens to an em dash and, in some configurations, a spaced hyphen to an en dash. This is why documents contain dashes nobody typed, and why the same document opened elsewhere sometimes shows them and sometimes does not.
It also breaks things downstream. A hyphen in a product code silently becoming an en dash means the code no longer matches. Two hyphens in a line of code becoming an em dash means it no longer runs. Turn the substitution off in anything where the text is data rather than prose.
The same autocorrect converts straight quotes to curly ones, with the same consequence in the same places.
Finding and fixing them
To see which you have, a character breakdown lists every distinct character with its count, so U+2013 and U+2014 appear separately rather than looking alike at 11 pixels.
To normalise, find and replace with a regular expression: [‒-―] matches the dash family and lets you replace the lot with an ordinary hyphen, which is the right move before putting text into a system that will compare it.
For the web, HTML entities — —, – — are still worth using where you cannot be certain of the file's encoding, though a correctly declared UTF-8 page handles the characters directly.
The short version
Hyphen joins words. En dash spans a range. Em dash interrupts a sentence. Minus belongs to arithmetic and nothing else.
Pick spaced or closed-up and stay with it. And do not accept the em dash as evidence of anything, in either direction.