Agarose gels can separate nucleic acids in several ways. The most common is by size, where smaller fragments migrate faster than larger ones. You can also differentiate DNA conformations — supercoiled, linear, and nicked circular — as they migrate at different rates.
To distinguish DNA from RNA, enzymatic digestion is useful: treat with RNase to remove RNA or DNase to remove DNA, then compare the patterns. Using denaturing agarose gels (formaldehyde for RNA, alkaline conditions for DNA) helps resolve single-stranded vs. double-stranded nucleic acids [Sambrook J, Russell DW. Molecular Cloning: A Laboratory Manual. Cold Spring Harbor Laboratory Press].
For visualization, dyes can be informative: EtBr, SYBR Green, or GelRed stain both DNA and RNA, while acridine orange fluoresces differently for dsDNA (green) and RNA/ssDNA (red) [Acridine orange for differential DNA/RNA staining (PubMed:30954273)].
Finally, for unambiguous identification, you can follow up with Southern (DNA) or Northern (RNA) blotting using specific probes.
In practice, people often combine size separation, enzymatic digestion, and selective staining to confidently differentiate nucleic acids on agarose gels.
Agarose gel electrophoresis are used for identification of DNA on the basis of size and charge. Agarose gel electrophoresis prefer Size based separation is the main method of differentiation.
The separated DNA fragment then run on southern blotting for identification of specific DNA sequences.