Evolution made this really simple for us. So simple that we need only three elements in situations like this to learn: an environmental cue, a behavior, and a result. In this case, walking up to a busy street (the environmental cue) is our signal to look both ways before crossing (the behavior). Crossing the street uninjured (the result) teaches us to remember to repeat the action again in the future.