The simple thing is that the oldest rule in is this, you NEVER try for peace from a position of weakness (Unless you are surrendering) Much like as soon as you start to talk with terrorists, the terrorists win (Also shown in DS9).
A real life example is the Israeli-Arab conflict. After the Six day war, Israel was in no mood to talk to their Arab neighbors since to be blunt, in the Six Day War, Israel kicked their butts and felt no reason why they would need to talk. After the 1973 war, when Syria and Egypt gave Israel some major worries, talks commenced and resulted in the Camp David accords which Egypt made peace, which secured Israel.
On DS9, where the Federation was in a war for its survival, the Dominion thought they had won till the final battles, and the Federation was going to hold the cure back as a very important prize to offer for a lasting peace, and to have a lasting peace, both sides have to trust that the treaty will be upheld. And the Federation and it allies, right or wrong, did not trust the dominion till they had defeated them.
The shock was not that they withheld the cure (Now if they didn't offer the cure are part of the peace process would be shocking) but that section 31 made the illness.