I think Will Smith suddenly felt the entire emasculation of his wife's Table Talk episodes about how Tupac Shaker is the love of her live (even though he's been dead years) and ran off with an 18 year old hottie. Yes, he's probably had affairs, but in the eyes of the world, he's been emasculated. Hence why he initially laughed, then when he saw her face, went up and slapped/punched CR.
For whatever reason unknown to the rest of us, Will is still besotted in an unhealthy way with Jada whatever she does, has put up with quite humiliating behaviour, and someone shone a light on it and he reacted.
It's unclear why she has this hold on him and why he had to prove himself to her at that moment, but he did.
He's very cross and angry IMO that his weakness (her) was exposed and this put him on the defensive.
I'm sure he has temper problems if he just does that, 99% of people would have said something, most would not have punched.