The dashes you described are known respectively as the en-dash and the em-dash. To describe the difference between their origins, Mental Floss writes:
An en dash (–) is bigger than a hyphen but shorter than an em dash (—). Th e names come from an obscure typographical measurement system, but the dashes have now taken on a life of their own in grammar. The em dash is the spork of English grammar: It ain’t particularly pretty, but you can use it for most anything. Em dashes can replace colons or sets of parentheses, or represent a sudden change in thought or tone.
So when do you use an en-dash? Again from Mental Floss:
To show numerical ranges, signifying “up to and including”—of dates, ages, pages, etc. (Example: “I read pages 7–22 last night.”)
The storied “compound adjective hyphen,” an event so rare in the English language that proofreaders shiver with excitement whenever they come across it. Basically “pro-American” gets a regular hyphen because “American” is only one word, whereas “pro–Falkland Islands” gets an en dash because “Falkland Islands” is two words. So, too phrases like “Civil War–era.”
What about an em-dash? From here:
Similar to an extended hyphen (-), an em dash is used to show a break in thought or a shift of tone.
If you'd like to read more about the differences between a hyphen (-), en-dash (--), and em-dash (----), see the blog post here which summarizes the above.