Mechanical gauges have direct, either mechanical, as in a dive shaft, connection to what ever they're measuring. (So for instance a mechanical speedo has a drive cable that connects (usually) to the gearbox. This physically turns the speedo needle via "mechanical" gearing etc inside the instrument.
"Mechanical" pressure and temperature gauges have likely capillary tubes that link to whatever they're measuring. Depending on the gauge itself, the tube isn't necessarily filled with the fluid being measured, but is directly acted on by it. For instance, it's not uncommon with an oil pressure gauge, to have the oil pressing against a sealed legible membrane in the pressure connection at the engine block, This then pushes a nice safe, inert, fluid up into the cockpit and into the gauge, where once again, it moves the needle mechanically via the internal mechanism.
Electrical gauges on the other hand, have a sensor that connect to the item being measured, whether engine rpm or water temperature etc. that sensor then sends an electrical signal back to the gauge, to move the needle.