I will often find a move to a different chord (not necessarily a key change), and when I find a move that I like, my brain immediately begins spitting out ideas for "what else happens" after the chord changes.
Here's a composition of mine. https://soundcloud.com/uneven-steven...se-for-comfort
The song starts in Gm. A brief bass intro hints at the groove to come, and then the A section comes in proper at 0:29. This is the first section I wrote; the rest were developed from there.
At 0:57, the groove stays in Gm, but the feel changes slightly, to emphasize the melodic change, which also features a move into the melodic minor scale in the guitar melody. At 1:10 the regular Gm part is reintroduced. These two parts are put together in AABA fashion.
At 1:25, the chords, still in the key Gm, move to Bb, Cm, and Dm, in ascending fashion. The guitar switches from melody to power chords, and the feel gets a little more "rock".
At 1:39, the AABA thing is repeated, but the guitar solos over the first two A's. Then we repeat the ascending idea. (Bb, Cm, Dm).
At 2:47, we use a lick that's been heard before in the song, but it usually goes back to Gm. This time (still in the key of Gm) we throw a little curve ball and go to Cm. This inspires a feel change for the mellower. There is a chord progression here, still in Gm, but much different than the rest of the tune (Cm, Gm, Cm, Gm, Am7b5, Daug). The progression repeats a few times while the guitar solos. With each repeat of the progression, the feel in the rhythm section builds, and at 4:13, we use a short drum break to get back to the top and restate the "head".
And finally at 5:27, we repeat that lick again, but this time expand on it a bit, using it as an outro.
Hopefully this gives you some idea of some of the ways you can take an initial idea into various different sections.