The wikpedia reference given by the OP in a comment says nothing about "playing voices in two keys simultaneously".
But the assertion that
I can't play a C major scale with a C# major scale it would clash
is not true in any case. The following example doesn't "clash," by any reasonable definition of the word. Every interval is (enharmonically, if not notationally) either a major or a minor third.
Theorists have invented "rules" for writing fugues, but their main purpose has been in marking student examinations, not composing music. One well-known rule book is the so-called "fugue d'école" which was written in the 19th century at the Conservatoire in Paris by Cherubini.
However, it's amusing that about three quarters of the fugues in Bach's "Well Tempered Clavier" would have failed the Paris Conservatoire's composition examinations. Of the eight so-called "essentials" in Cherubini's marking scheme, many of Bach's fugues only contain two or three, which is hardly a passing grade!
In fact, a fugue doesn't have to be in a "key" at all. Here is an example of one which is not. Note: the duration is about 60 minutes - somewhat longer than Bach's fugues. Don't be fooled by the slow start - things start to get more exciting after the first 10 minutes or so...
Of course some people (and perhaps the OP) might not consider that fugue by Sorabji to be "music" at all - but not everybody shares that opinion.