You’re going to be able to find a lot more in depth answer here. But the short of it is:
– : This is a hyphen.
– : This is an en-dash.
— : This is an em-dash.
The hyphen is used to connect words, like you say. Ex: Twenty-two, ex-boyfriend.
The en-dash is used in the context of a span of time. Ex: 1996–2018, February–March.
The em-dash is used when inserting a thought. Ex: He wouldn’t—couldn’t—go home.
Good question! Hope this helps 😊