Gel matrix provides a medium with pores unlike a liquid medium where there is no resistance to the movement of DNA molecules. Therefore, in electrolyte buffer between two oppositely charged electrodes, DNA molecules which have inherent negative charge density due to its phosphates, moves towards the positive electrode. Here, the pore size could be controlled by the concentration of the matrix (e.g. Agarose or PAGE) in the Gel to increase or decrease the resolution of separation.
You can tell exactly which conditions you have tried, that will help to diagnose the problem.
Particles move in the solution based on their charge/mass ratio. As the mass of DNA increases, slowing migration, its negative charge increases, countering the effect of mass.
Very short or slow electrophoresis may result in incompletely resolved bands.
It is possible that you are using too much DNA per lane; usually use 50 ng per mm of lane width (i.e. the width of one tooth on the comb).
Did you precipitate your DNA with isopropanol or EtOH? Which salt did you use? Was the precipitate following an organic extraction (carry over of solvent or protein from organic/aqueous phase separation). My guess is you most likely have over dried the DNA pellet, or have protein contaminant carry over.
Both answers are right. To put it simple. The mass / charge ratio of DNA is constant. That the reason, why all molecules move with the same speed in liquid in an electrical field. The network of a gel causes friction, which increases exponentially with the length of the DNA molecule. With the right gel density your can choose your separation range