Every possible metal combination creates a small voltage that varies with temperature. For most metals commonly used for conductors (wiring) the voltage is too small to be useful. Some alloy combinations generate a voltage large enough to be useful, and that’s what thermocouples are made from. The Type K thermocouple commonly used in EGT probes has a Nickel-Chromium alloy on the + side and a Nickel-Aluminum alloy on the – side. When you connect those wires at the “hot junction” you get up to some tens of millivolts. At the other end where the thermocouple is connected to copper wires (the “cold junction”) it's colder so you get a lower voltage, in the opposite direction. From the difference between the hot and cold voltages you can calculate the temperature difference between the hot and cold junctions.
Note that a thermocouple by itself can't give you an absolute voltage, just the difference difference between the hot and cold junctions. Thus the gauge is calibrated assuming a standard temperature for the cold junction (commonly a 32°F ice bath for precise laboratory measurements or 60°F for real world measurements). Some gauges may include some other means to measure the cold junction temperature and compensate the reading accordingly. I can think of a number of ways to do that but I don’t know what’s common in aircraft instruments, I’ve only used the uncompensated ones.
What that means for an uncompensated gauge with the cold junction being at ambient temperature is that if the air temperature rises, the indicated temperature will be lower for the same actual engine temperature. So assuming you have a gauge calibrated at 60°F and your EGT is 1400 and the outside air temperature is 90°F, the gauge will read 1370, not the 1400 the engine is actually operating at.
Now if the cold junction is inside the engine compartment where it could be even hotter, well, you can do the math. Ideally, you would keep the cold junction at the temperature it’s calibrated at. If the extension wires all the way back to the gauge are the same Ni-Cr and Ni-Al then the cold junction is at the gauge and if you have cabin heat so it's never too hot or cold behind the instrument, the gauge will be reasonably accurate.