One of the first things I learned, before driving on the road, was just because you have a green light, does not give you the right to enter the intersection. If you read the Traffic Code, you are still required to enter an intersection when other vehicles do not present a danger of entering it. I wrote many citations for accidents, just like you avoided, for both vehicles, the one running the light and the one that didn't clear before entering.
Don't start looking down road, as you come up to a stop sign, wait until you are there, stopped and look both ways, then proceed. You will have less of an urge to run a stop sign, thus avoiding an accident that could possibly injure you, others, or worse.
When waiting for a light to change, begin scanning the roads to your left, right and in front of you, for any vehicles that might be approaching that will not possibly stop in time if the light should change. Don't focus on the green light. This is especially true for motorcycle riders.
Drive Safe, Drive Smart.
b