Is gefahren "I went (by car)" and gegangen "I went (by foot)"? My teacher said "ich habe schwimmen gegangen". Would you be able to say "ich habe schwimmen gefahren" if you went by car? Does that work and make sense?
I hope your teacher said
Ich bin schwimmen gegangen.
That means you went to the pool. By any means of transport.
Ich bin schwimmen gefahren.
means you went by car, bus, tram etc. OR it means you went on a trip with swimming as the main topic. That is because fahren can also mean to go on an excursion. Context decides this.
Hast du schon Urlaubspläne? — Wir fahren an die See.
Do you have any holiday plans? — We go to the sea.
Yes, you may well say "Ich bin schwimmen gefahren".
(But note that it is correctly "Ich bin gefahren", not "Ich habe gefahren".)
This means that you took a vehicle for the trip; usually one you drive yourself, for example a car or a bicycle; whereas, when you take a bus, you are slightly more likely to say "Ich bin schwimmen gegangen"; but the difference in probability is really small; some people may well say "Ich bin schwimmen gefahren" when they took the Bus. However, at least for my feeling, something 'is not quite in order' with this usage, it is somehow uncommon.
If your teacher said "Ich habe schwimmen gefahren", he either is not a native speaker (and has missed something in his teacher training), or he is a native speaker from one of the Southern regions of Germany or from Austria where strong dialect is in everyday use. But you should not use this (unless you want to make a joke).