I'd say it matches your first definition, although in this context the second one is an implied consequence. I would just make a small adjustment to your first definition - you are not trying to eliminate a bad effect of something you have done, but the bad effect of something that has happened beyond your control (that's what the rest of the sentence "pretty much anything that goes on on the roads" means).
The whole paragraph can be transformed into a sequence like this one:
you acquire defensive driving skills so that when
you are driving -> (and) something unexpected, potentially dangerous happens on the road (beyond your control) -> your habit kicks in -> you automatically perform a defensive maneuver -> the effect of this maneuver counters the effect of the unexpected event -> you emerge from the incident safely, without a crash (without bad consequences)
the bold part corresponds to the meaning of 'compensate for' in your context.
I would read it as the 2nd definition from ODO:
[no object] (compensate for) Reduce or counteract (something unwelcome or unpleasant) by exerting an opposite force or effect