In X-ray and CT studies, the contrast dye is substance that absorbs the X-ray photons, and does not allow them to be detected by the X-ray film or CT scanner. Contrast dye can be injected into your blood vessels (to show the vessels), it can be ingested orally (to show the upper gut), or inserted into the rectum (to show the lower gut). In some CT scans all three types of contrast (so-called "triple contrast") is used.
MRI contrast works differently, but also accentuates the differences between tissues. The MRI contrast alters the magnetic properties of tissue. The altered properties will differentiate tissue types on the MRI image.