The NIMBY theory is probably part of it, but definitely not the full story. For one, Toronto and Vancouver's population density is on par with major european cities (Toronto is about the same as Berlin, and Vancouver same as London). Arguably most european cities have similar affordability problems, but if NIMBYism is an issue, it's not particular to Canadian cities.
My pet theory is it all comes down to money supply. All that money generated out of nothing through quantitative easing over the last decade+ had to end up somewhere, and it's settled in real estate and equities. If that's the case, then the end of QE and "balance sheet pruning" is going to put a stop to this... and likely pop a giant bubble in the process. That's a scary prospect for countries like Canada and New Zealand, where RE has played such a huge part in inflating wealth.