it comes from the first world war.
in the trenches most of the soldiers smoked (on both sides). the first light would alert the sniper, the second would allow him to take aim and on the third he would fire. so even then smoking was bad for your health!