What is the methodology for assigning airport codes?
There are different kinds of codes assigned to airports. IATA codes, which are the three letter codes you mention; are for travel industry identification purposes (by the way, these aren't restricted to airports - train stations also have these codes). These are used by airlines and travel agents.

The other four letter codes are ICAO codes. These are used for navigation, air traffic and flight planning.

ICAO codes have a defined standard, each region is assigned a letter and all codes begin with that letter. Canada is assigned a practical C, US is K:



IATA codes however, are arbitrary. For some reason, Canada was given 'Y' and so all IATA codes in Canada begin with Y.

There is YYC (Calgary), YVR (Vancouver), but then you have YQX (Gander) and YXS (Prince George) and YUL (Montreal-Trudeu).