Do you know how C minor and G major related?
One key has 3 flats and the other - 1 sharp, right?
Now the rule of thumb is that the more difference in terms of accidentals the keys have, the less related they are.
So C minor and G major should be situated pretty far apart on the circle of fifths, shouldn't they?
But they're not. They are very closely related.
You see, the tonic chord of C minor (C-Eb-G) has Eb which is the lowered 6th scale degree of harmonic G major. This makes C minor the subdominant key of G major.
And G major - the dominant key of C minor because the tonic chord of G major (G-B-D) has the B natural in it. This is a sign of C minor harmonic version.
Knowing this, you can understand why sometimes you see these strange juxtapositions of keys in your organ pieces.