If you're friend wasn't from a Visa Waiver country, then they'd need to get a Transit Visa anyway, whether they were just changing planes or entering the country formally. The list of countries needing that is here. Getting a Transit Visa is free, but you do need to apply in advance.
For your friend, he'll be arriving as a visa exempt visitor, so will need to enter Canada anyway. At that point, he's in the country, so is fine to leave the airport. However, if he only has a few hours, he may struggle to get very far once he has passed through immigration, and factored in the queue to clear security again!
Canada is like the US, and requires you enter and leave (for the purposes of immigration) when changing between international flights. (Some people on their way through Canada to America who have US visas now don't need a Canadian transit visa too, but this is fairly recent and only covers some countries).
(It's not like somewhere such as Singapore, which doesn't require visas for international transit, and even has hotels on the airside so you don't need to clean immigration just to have a kip! Singapore also sometimes does short visit visas for people with a long layover, often including a free city tour, but it's a very different setup to Canada)