The NHL had 70 games on the schedule during the original 6 era. With expansion, they started adding games. In 67-68 they went to 74 after adding 6 more teams. They re-did the schedule to 76 games the next season. Then they added 2 more games with two more teams in 70-71, bringing it to 78. They didn't add anything with the next two teams, but when they expanded to 18 in 74-75, they jumped to 80. They kept 80 games when they contracted in 78-79 to 17 teams, and still kept it when they expanded to 21 in 79-80. After expanding to 22, then 24 by 92-93, they added 4 more games including 2 neutral site ones and kept that schedule for one more season (i.e. the Rangers played 2 games in Halifax in 93-94). The 95 lockout, they removed the neutral site games, and that's how we got to 82. I'm sure at the time of the changes, there were schedule matrix reasons for the numbers they played. Pretty much lost to history.
In contrast, the NBA has existed at 82 since the late-60s. No one really knows why.