It's even more specific than that. There are three common dashes in typography, each with well-defined uses: hyphen (-), en dash (–) or em dash (—).
https://www.thepunctuationguide.com/hyphen-and-dashes.html
I learned that there are at least four, although they are often collapsed in typefaces that do not have separate glyphs.
A hyphen (-) is for port-manteau words, and for words broken at a syl-
lable at the end of a line of text.
A figure dash (‒) is for separating groups of digits in a phone number or other sequence. 1‒202‒456‒1414, or 747‒400. This is the one that is most commonly substituted with a hyphen because it's hard to type.
An en dash (–) is for a range. The notes on a piano are from A0–C8. The bank is open from 9–5. This is also often substituted with a hyphen.
An em dash (—) is for appositive or indirect remarks—like a gloss of a quoted phrase—and usually used in pairs. It can also serve to mark speech—as in
Ulysses—although this may be seen as eccentric.
—That's a fine old custom, he said. I'm glad to see it has not died out.
There are other specialized dashes used in mathematics, but those are not needed in mainstream books.
By the way, the "en dash" is so-called because it is meant to be the same width as a lower-case n. The "em dash" is meant to be the same width as a lower-case m.