Perhaps surprisingly, the accepted answer at "A place nearby" but not "A place good" answers this. However, that question title is not an intuitive match for this problem, and the relevant sentence is a bit buried.
In the phrase 3-month retreat, the main noun is retreat and three-month serves as an adjective (or an attributive noun, I suppose). Because it has more than one word, a hyphen is necessary to keep all the parts of that adjective together. Because it's an adjective, it remains month and not months: preceding adjectives are not inflected for number.
This serves for other similar collocations:
- a six-foot coffin
- a ten-year-old boy
- a fifty-six-page book