Only once hit at the very beginning seven years ago, a car squeezed by and hadn't even passed yet when he right-hooked me. At the time I didn't realize that a licensed driver could be so stupid as to pull a stunt like that so my first thoughts were disbelief.
I've had potentially near misses since then and like you I want to analyze the situation, my frame of mind and my actions. I've come to realize that it only takes a momentary lapse or a tiny mistake in the wrong situation in traffic. Much more so than when driving, above and beyond being more vulnerable physically. So I give myself more room for error, more than I'd think I generally need.