They Need A Large Library Of Samples

How it works is that if a genetic anthropologist has a DNA sample, they can compare it to their library of other samples. Through this, they can understand which groups in their collection the sample is closely related.
When getting down to the nitty-gritty, your paternal ancestry is tracked thanks to the Y chromosome. It is what fathers pass to male descendants. For maternal ancestry, this is found in mitochondrial DNA, which is what a mother passes onto all their children.