In practical applications, you obtain only a finite number of samples of the signal. The fast Fourier transform (FFT) assumes that this time record repeats. If you have an integral number of cycles in the time record, the repetition is smooth at the boundaries. However, in practical applications, you usually have an incomplete number of cycles. In the case of an incomplete number of cycles, the repetition results in discontinuities at the boundaries. These artificial discontinuities were not originally present in the signal and result in a smearing or leakage of energy from the actual frequency to all other frequencies. This phenomenon is spectral leakage. The amount of leakage depends on the amplitude of the discontinuity, with a larger amplitude causing more leakage.
A signal that is exactly periodic in the time record is composed of sine waves with exact integral cycles within the time record. Such a perfectly periodic signal has a spectrum with energy contained in exact frequency bins.
A signal that is not periodic in the time record has a spectrum with energy split or spread across multiple frequency bins. The FFT spectrum models the time domain as if the time record repeated itself forever. It assumes that the analyzed record is just one period of an infinitely repeating periodic signal.
Because the amount of leakage is dependent on the amplitude of the discontinuity at the boundaries, you can use windowing to reduce the size of the discontinuity and reduce spectral leakage. Windowing consists of multiplying the time-domain signal by another time-domain waveform, known as a window, whose amplitude tapers gradually and smoothly towards zero at edges. The result is a windowed signal with very small or no discontinuities and therefore reduced spectral leakage. You can choose from among many different types of windows. The one you choose depends on the application and some prior knowledge of the signal you are analyzing.