If you are composing for a continuous performance, such as a musical, or putting together tracks for an album meant to be listened to all the way through in order, then it is a good idea to vary key or scale after some time so your listeners don't get tired of hearing the same thing.
In recording projects I generally try to avoid putting more than three pieces together with the same tonic (i.e. all in D). Changing rhythmic variation and scale (major vs. minor) can help, but I find too much "sameness" after about three pieces.
For musicals I find that the compositions will often need to be altered to a key that suits the principal singer(s) range, changing it up anyway. Otherwise I make the attempt to have some variation between songs. It also depends on how much time there is in between songs, and what incidental music is put in between. The incidental music can borrow the themes from the songs to change the feel or emotion (put the love theme in minor when the tragedy happens, increase the tempo of the Hero's theme in the action sequence).
Going to related keys seems to me to have a better flow. Some easy transitions I've found are:
Going to the dominant of your previous key (up a 5th) works well, especially in continuous music transitions.
Switching to parallel minor to get to the minor's relative major (such as going from G major to G minor then transitioning to Bb major)
Changing to the relative minor.
Chromatic and Step-wise transitions will also work, but if there is too much time in-between the change you can loose the sense of the change and it will sound like the previous key, especially in chromatic changes. Transitioning downward (such as C to B or Bb) can make the music feel like it is dragging, or cue sadder emotions.