Tl;dr: there is a whitelist for transit visa waivers, so citizens of some countries need to apply for a transit visa in advance. However, you can apply from a waiver if you normally need a transit visa but you are going to/from the US, Canada, Australia or New Zealand. You can also get a waiver if you are resident in the US, Canada or EU/EEA, irrespective of your citizenship.
Tl;dr: there is a whitelist for transit visa waivers, so citizens of some countries need to apply for a transit visa in advance. However, you can apply from a waiver if you normally need a transit visa but you are going to/from the US, Canada, Australia or New Zealand. You can also get a waiver if you are resident in the US, Canada or EU/EEA, irrespective of your citizenship.