It's 2 fold because it got so expensive but also other countries are playing and the Internet gives the game global exposure.
Just 20 years ago kids outside of NA could only read about nhl players for the most part now you have youtube highlights of every star. I can't remember which player but I remember one Swedish player (I think it was Forsberg) saying he had never seen a wayne gretzky highlight or anything and the first time he ever saw him play was when he got to the NHL and played against him. Imagine kids in sweden never seeing McDavid until they made the nhl, you could never attempt to emulate what doesn't exist to you.
It's not that different from usa and basketball where they absolutely demolished everyone but now the games are close. Much like canada, they still win most best on best tournaments but they aren't steamrolling everyone anymore.
Too add to that, other sports are becoming more popular in Canada for the same reasons. Kids in Canada can watch and follow any sport - when I was a kid none of my friends followed soccer but it's very big now, basketball is also much bigger. This is partly due to the exposure and partly due to Canadas increasing diversity. It was only a matter of time before football (soccer) grew in popularity as it is far and away #1 in the vast majority of countries. These sports are also cheaper too. Just a bunch of different things all happening at once that are leading to a lower percentage of kids playing hockey.