2 Samuel 12:22tsum
He said, "While the child was {still} alive, I fasted and wept; for I said, 'Who knows, the Lord may be gracious to me, that the child may live.'
David explains he fasted hoping the Lord would be gracious.
1 Samuel 7:6tsum
They gathered to Mizpah, and drew water and poured it out before the Lord, and fasted on that day and said there, "We have sinned against the Lord." And Samuel judged the sons of Israel at Mizpah.
Israel fasted while confessing, "We have sinned against the Lord."