You ask someone if they can help you with a problem, and instead of giving you a simple yes or no answer this individual uses the opportunity to attack you and says if you hadn't done that, or if you had done that before, this would not happen to you.
One idiomatic phrase that may be relevant is Job's comforter. William Benét, The Reader's Encyclopedia, second edition (1965), has this entry for the phrase:
Job's comforter. One who intends to sympathize with you in your grief, but says that you brought it on yourself, thus in reality adding weight to your sorrow.
The reference is to a central element in the Old Testament's Book of Job. Three friends—Eliphaz, Bildad, and Zophar—come to see Job after multiple calamities have befallen him (through no fault of his own); and they argue, consecutively, "If thou wert pure and upright; surely now he [God] would awake for thee" (Bildad), and "God exacteth of thee less than thine iniquity deserveth" (Zophar), and "For thine iniquity teacheth thy mouth ... Thine own mouth condemneth thee" (Eliphaz). Job then responds, "I have heard many such things: Miserable comforters are ye all." (All quotations are drawn from the King James translation of the Bible,)
Try “No good deed goes unpunished.”
To quote Wikipedia:
The phrase 'No good deed goes unpunished' is a sardonic commentary on the frequency with which acts of kindness backfire on those who offer them. In other words, those who help others are doomed to suffer as a result of their being helpful.
To quote Greybeard
An alternative, particularly on the internet, would be "I tried to help and he flamed me."
You may be describing a "turncoat" a "fair-weather friend" or a "critic."
3/26/2020: Edit in response to comment below:
turncoat: n. 1. One who forsakes his party or his principles; a renegade; an apostate; a defector to the enemy.
fair-weather: 2. Appearing only when times or circumstances are prosperous; as, a fair-weather friend.
critic: 2. One who passes a rigorous or captious judgment; one who censures or finds fault; a harsh examiner or judge; a caviler; a carper.