Why did Shostakovich not release his 4th, but did release his 5th symphony? (The 4th was released eventually, just not when it was written)
It's explained from page 84 of Shostakovich: A Life by Laurel E. Fay. Stalin went to a performance of "Lady Macbeth of the Mtsensk District" and left early. Two days later (28 Jan 1936) an editorial appeared in Pravda attacking the opera, with a further editorial on 6 Feb 1936 attacking The Limpid Stream. By the time of the scheduled premiere of the 4th, on 11 Dec 1936, the situation was pretty difficult. Shostakovich had finished a Mahlerian formal symphony which was in total conflict with the expectations of the Party leadership. Even the musicians got nervous about playing it. So a jittery Shostakovich, possibly with the involvement of the conductor Stiedry, pulled it. It's quite hard to imagine what it must have been like to try to compose music in the Terror of 1936-7.
Shostakovich began writing the 5th, making it less complex and more optimistic (though he later maintained that the optimism of the music was clearly under duress). He managed to get the politics and music right in producing, as he described it, "a constructive creative answer of a Soviet artist to just criticism," to rapturous applause in late 1937. How he did it is more of a question for a classical music forum, not a history one.