Gradient coils in MRI create spatial variations in magnetic field strength, enabling three-dimensional imaging through pulse sequences in different directions (x, y, z). They facilitate functions like slice selection, phase encoding, and frequency encoding by adjusting resonance frequencies of protons. RF coils act as antennas that transmit and receive signals, with different types serving specific imaging needs for varied anatomical regions.