Why do DNA fragments separate into bands

Gel electrophoresis is a process with which molecules can be separated from one another and made visible.

A gel electrophoresis apparatus essentially consists of a gel matrix through which molecules can migrate. The gel matrix panel is electrically charged. One side serves as a cathode (negatively charged) and the other side as an anode (positively charged).

Gel electrophoresis sequence:
Molecules are of different sizes and therefore also to different degrees or weakly charged, which is why they move further or shorter through the gel matrix depending on their charge. In addition to the charge, the gel itself also influences how far the molecules move, because: long molecules are more likely to be prevented from moving than short molecules. In this way, molecules with the same size or charge are grouped together in bands.
The DNA is now introduced into the matrix. Deoxyribonucleic acid is negatively charged with anions because of its phosphate and consequently moves towards the anode.

Again to the general overview:
Anions (negatively charged) migrate towards the anode (positively charged)
Cations (positively charged) migrate towards the cathode (negatively charged)

Gel electrophoresis is used to create a genetic fingerprint:
Example 1 (criminal cases): If one extracts the DNA from a blood sample / sperm sample / skin cell found at the crime scene and compares it with the possible perpetrator, the band sequences would be identical in the event of a match.
Example 2 (paternity test): paternity tests can also be evaluated according to the same scheme. The DNA of the potential parent is compared to that of the child. Both samples are reproduced with the aid of the polymerase chain reaction (PCR) and made visible by gel electrophoresis. If there is paternity, the gang pattern will not be identical, but due to the relationship there will be matches in the gang pattern.