To shoot oneself in the foot / To work against one's own interests
Literally 'to throw stones at one's own roof'. Describes acting in a way that damages your own interests or situation.
Criticising your own team in public is shooting yourself in the foot.
With that comment you shot yourself in the foot.
—Why did she say it? —She shot herself in the foot, I don't know why.