Tradition. Time was when composers wouldn't always change key signature even when there was a clear change of key. For example, it's usual in Classical sonata-form movements for the second subject to appear first in a different key from the first subject, but the key signature to stay the same even if a change would mean easier notation. A striking example here is Beethoven's piano sonata 21 in C ("Waldstein"), where the second subject's first appearance is in E major, entailing about a hundred accidentals. In that era, composers seem to have regarded key-signature changes as suitable only at points that are important in the movement's structure. And what would indicate the close of one section and the start of another? A cadence that indicates a change of key -- as Tim suggests in his answer.
Here are two examples from the first movement of Beethoven's piano sonata 8 in c minor ("Pathétique"), where the music leading up to the key-changing cadence entails several accidentals but the key-signature doesn't change until the cadence itself.
At the start of the development, where the key is already g minor, and modulates to e minor:

In the transition from the development (which modulates through various keys) to the recapitulation (in c minor):

Composers would later get less reluctant to change key-signature (including Beethoven himself) but the legacy of this old tradition remains to some extent.