If dogs are colorblind, how can guide dogs know when a traffic light turns green?

They don't.

The human handler is responsible for listening to traffic and knowing from which direction it is coming. Sometimes you can hear a grinding click sound when the lights change, while in some countries there is an audible beep to tell the blind when the light has changed.

If the handler gives a "forward" command and the dog sees or hears a car coming at them, the dog disobeys the "forward" command. So the dog focuses only on the cars, not on traffic lights.