This might be a stupid question, but if I have, say, two or three viruses and a Trojan on a Windows machine, could I end up infecting an EXE file that I compiled myself?

It's not a "could". Such a machine should be considered compromised. Anything you type or watch is not under your control on such a machine and you can consider that it's being observed and logged by malicious actors. Anything you considered to be secure that went through that machine lost its security completely. This includes passwords, documents, and code compilation, if not even the motherboard's firmware, which means that even reinstalling the operating system is no longer a secure operation, as the malware can reinstate itself from the MOSFET.
What to do to fix this mess? You'll need:
- a hammer
- a can of gasoline
- an electric lighter
- some super glue
- mask gas
- some safe area (ideally, a deserted wasteland)
Smash the RAM and disk drives using the first tool, to kill the disease.
Remove the CMOS battery (the only component that can safely be reused)
Place the infected components onto a solid, non-inflamable ground.
Put the mask gas over your head.
Carefully cover the rest of the electronical devices in gasoline (make sure you don't fully empty the can)
Step away around 10-20 meters, while applying a thin but consistent trail of gas, without interruptions.
Apply some super glue to the lighter's switch (the movable components).
Wait 20 seconds.
Fire up the lighter. Gently, but generously blow on the glue, until it keeps the switch on.
Throw the lighter onto your end of the gasoline trail.
Run. Stop over at the nearest PC shop and ask for a healthy computer. It's not guaranteed it's not already virused as well, hopefully it's not, who's to know? If needed, repeat the procedure.