It's ironic, isn't it - we need teachers to build positive relationships with students, which means relating to them, yet teachers are also expected to be so perfect as to be unrelatable.
If smokers' staff rooms were still a thing (they used to be off the back of the main staff room) then students would not be in a situaion where they'd see staff smoking outside the gates. If breaks were a reasonable time, staff would be able to go and smoke away from premises.
Back in my day, our teachers used to hang out in the smokers' corner, together with the kids, when the weather allowed. It was age-restricted, of course, but it meant you always had more staff outside, technically not on duty, but present anyway (the same way free food in the canteen and separate eating spaces meant more staff to techinally supervise there). Some of the best relationship-building happened in those smokers' corners, where staff would have casual chats with the kids, who were often from more problematic families.
I've always found the code of conduct a bit over-reaching. Sure, when I am at work I represent work and my employer, so I bend to their rules. But when I am not? I am not paid to be on constant duty, not paid to always be on my guard. It is healthy for students to see that their teachers are normal people and don't shut themselves into the broom cupboard at school at the end of a day. I don't smoke, but I have my vices, like everyone else.