Every Fugue has its own form. A form is created by alternations of
expositions (sections with full statements of the subject) and episodes.
As a fugue develops, it often modulates to several different closely related
keys before returning to the tonic key. The first exposition usually has
an short episode within it (after subject and answer) that harmonically
prepares the next statement of the subject on the tonic. Sometimes (if
the answer is in the dominant key) the function of the episode is to provide
a modulation back to tonic. Most of the later episodes are longer (they
greatly vary in length).
Example: Bach, WTC I, Fugue V in DM
This episode functions as a modulation from em back to the tonic
DM.
These three measures are followed by a iii - vi - ii - V - I circle
progression, in which the modulation to DMis fully established with
a cadence.