[If] a good deed happens to you," meaning: victory, "it distresses them," that good deed.
"And if a disaster befalls you," meaning: a catastrophe from the polytheists, "they say, 'We had taken our matter [in hand] before,'" meaning: we have taken precautions by opposing Muhammad and staying away from him. "And they turn away," to their homes, "exultant," over the catastrophe that has afflicted the Prophet (peace and blessings of Allah be upon him) and the believers.