"First it's G major, and then down to E minor, and then straight to B major(?) then back to A minor and to G major again."
As Tim pointed out, this piece is firmly in E minor. The key signature is the first hint - one sharp indicates either G major or E minor. The fact that the piece starts with an Eminor chord is the second clue. (The upbeat starts with 1st inversion E minor, and then on the weak beat we pass through to start firmly on a root position E minor. In both cases the fifth is omitted from the chord, but esp. in 2 voice counterpoint this makes sense, as it is the weakest chord tone, and has the least impact on the identity of the chord.)
Now that we know it is in E minor, we should not be surprised to see a raised 6th and 7th degrees, esp. in ascending melodic lines. These altered degrees are very conventional in diatonic minor mode, this is known as "melodic minor scale".
In m2 (3 if you count the upbeat) we also see that the raised degrees are back to natural in a descending line. This too is part of the entire convention surrounding melodic minor mode. Also the raised 7th degree in measure 5 is completely expected - the raised 7th degree is approached in a descending line from the tonic e, but immediately returns back to the tonic again. This is also expected - a raised seventh like this has the effect of making it a "leading tone", which "wants" to go back to the tonic, thus again reinforcing e as the tonic. The first chord in m6 is again E minor - exactly as expected.
The only place where the center of tonality briefly changes is in measure 8 where we briefly feel a tonality of G major (the relative major of Eminor) This is achieved by the chords of m7. First beat of m7 is G, 2nd beat is C, and least 2 beats are D - so in retrospect this sounds as a I-IV-V progression in the key of G major, which then cadences into G in m8.
It is only a brief escape: since G is only the relative major of E minor, and since the harmony moves real quick, and doesn't overly stress the D chord it is easy to immediately roll back to Eminor (by easy I mean it doesn't offend the ear to continue in Eminor as if this entire cadence didn't happen). If you know this entire piece you'll note that it does - at least, the 1st time around, the 2nd time around the piece moves on in G major for at least a while.
There is no particular Baroqueness with regard to the treatment of the tonality - this kind of harmony was also common in Renaissance, and also in the classical period. What is rather Baroque, or at least, typical for Bach is the lively counterpoint, and systematic persistence of the motive (the duh-duh DUH motive that is characteristic for the Bourree).
Other popular changes in the center of tonality can be to the dominant or subdominant - keys that have all but one tone in common with the key of departure. Whether such a change in tonality persists and can be called a modulation depends on how strong the confirmation of the key is (a strong I IV V7 cadence is a strong confirmation and more likely to establish a new key), and also depends on how long the piece continues in the new key.
Note that a (temporary) change in tonality may or may not be denoted explicitly using a new key signature. In practice you'll find that in Baroque music, the tendency is not to denote those changes explicitly, esp. not within one movement.