I dont understand

I was having sex with my bf (unprotected) and he wanted to try anal, i want to for it but we tried it and he enjoyed himself (but he will never flip sides.) but after we finished anal i bursted into tears right infront of him. I told him that my ex (one i tried anal with) had popped into my head and the saddness and misersery he put me through hit me like a train. I got overwhelmed and iapologized to my bf for even letting it happen but we still dont know why it happened.... Anyone got any clues or even i thought as to what happened to me?