If you need to travel through another country before entry into Canada (layover, flight connection(s), etc.), you might need to request a Transit Visa for that country, even if you do not leave the airport.
United States
If you need to transit through the United States, you need to be authorized to enter American territory.
You could be eligible for the Visa Waiver Program. To qualify, you must be a national of a participating country, hold an electronic passport, and request an Electronic System for Travel Authorization (ESTA). If your passport does not meet the criteria, or if your country does not take part in the Visa Waiver Program, you will need to ask for an American transit visa.
other countries
Should you require transit through another country, it is important to verify its entrance requirements. Contact the closest diplomatic mission of that country (embassy, consulate, etc.) to determine if you need a transit visa.