@Guardian25
@JorgeDavid
@Henry Ng Tsz Kiu
Regarding the other issue, we can find in the books what was previously said: "Actually in music history, a tonal answer with the fourth and fifth interchanged in the answer is a default rather than a strict real answer in Bach's time. (I remember it's from the book "Theories of fugue from the age of Josquin to the age of Bach" by Paul Walker, but I'm not sure whether it really does come from there). It may not be a theoretical reason, but rather a historical reason Bach choose to write with tonal answer."
Specifically, the degree that is affected by this change is the 5th of the key. Thus, in the fugue in Gm, the note that changes is D (the 5th) and in the fugue in Cm it is G (the 5th).
In fact, what we can also read in the books is that "when the 5th appears noticeably in the subject, especially at the beginning, a 4th (just that note) will be transposed"......
But why or what for?
I think there is a tonal or, rather, a tonal transition reason.
As the beginning of the fugue begins in Gm, the answer "must be in the key of the dominant". If the first note of the fugue (D) had risen to a fifth (A), the dominant harmony would have already been almost defined by the fifth and the fundamental. However, Bach did not want the modulation to be so abrupt, in fact in measure 3 the F natural still appears and not the sharp. So it is prolonging the dominant. In this way measure 4 can be interpreted as having modulated to Dm or is still in Gm. When the third entry occurs in measure 5, it returns to Gm by means of a clear dominant.
This is why it is the "rule": when the fifth a appears noticeably in the subject, a tonal response is appropriate, and the fifth is transposed a 4th.
The same applies to the leakage in Cm. The 5th (G) appears early in the subject.
When it is transposed in measure 3, if it had been transposed as a 5th, it would have been a D, and the key of G would have been Definite.
But transposing it a fourth (C), the key is still Cm, according to what sounds underneath. Yes, even though there is an F#, but this is a passing and a tonicization, insufficient to establish the new tonality. This tonality is not established until the end of measure 4 and the beginning of measure 5, in that cadence. It has modulated to Gm, but in these two transitional measures 5 and 6, the dominant G7 appears for the new entry in measure 7.
In this third entry, the note remains as at the beginning, because the interest now is to reinforce the key of Cm again, so it makes more sense to leave the note as G than as F.