Hi, Gordon. I echo Gary's comment about "vague and confusing" terminology. This resulted from the extremely successful ad campaign by Ancestry several years ago where we were told whether we should buy lederhosen or a kilt, an African gele or a Scandinavian tophue.
It was all about marketing, and "ethnicity" was a word that the general public recognized and--and least partially--understood. Problem is, ethnicity isn't a term that technically applies to genetics. For that, in context, what we're actually talking about is "admixture" or "biogeographical ancestry." But good luck getting an advertising company to recommend trying to use "admixture" to connect to a general audience when "ethnicity" is there to be used for the "where do I come from" question.
Here's an article on the ISOGG Wiki that might help: https://isogg.org/wiki/Admixture_analyses.
I wrote about the "ethnicity testing" issue several years ago on my essentially defunct blog, "Should You Trade Your Lederhosen for a Kilt?" We've come farther since then, and the Genome Research Consortium has delayed indefinitely moving the current genome reference model from GRCh38 (we still use the 11-year-old, deprecated GRCh37 at the genealogy testing companies, unfortunately) to GRCh39, which had been anticipated for a 2022 release. The reason for the delay is the work done by the Telomere-to-Telomere Consortium to finally sequence the entire human genome. Prior to that, roughly 6% of the genome had remained invisible to us.
Not to complicate things, but what that new, hybridized sequencing technology allowed us to consider was moving from a single-model reference genome (the majority of which is from one guy in Buffalo, New York, who, back in 1997, answered a newspaper add about DNA testing) to what's referred to as a pangenomic model. Oversimplifying, we know that that different populations have different allele frequencies and different structural variants called tandem repeats. Having a single reference genome makes less sense now than it did 20 years ago. For a short background on pangenomics, here's a five-minute YouTube video: https://www.youtube.com/watch?v=swNtGe9QWAQ.
Increasing the identifiable diversity of our genome reference models through fully-sequenced data may help us improve the accuracy and granularity of biogeographical ancestry. But that's still a bit in the future.
The AncestryDNA links that Paul gave in his answer probably satisfy the question about how they come up with their periodically changing "ethnicity" estimates. For a slightly deeper dive there, here's the PDF version of their "Ethnicity Estimate 2023 White Paper".
But since you requested scientific background, here are a few items that can help put you to sleep if you suffer from insomnia any given night. This is by no means an exhaustive list and, frankly, most of the literature deals with psychological and social issues surrounding consumer DNA testing and "ethnicity" rather than the actual mechanisms of analysis. Just in case you want to browse:
Open Access Articles
Blanchard, Jessica W., G. Tallbull, C. Wolpert, et al. "Qualitative Research Barriers and Strategies Related to Genetic Ancestry Testing in Indigenous Communities." Journal of Empirical Research on Human Research Ethics 12, no. 3, 169–79 (July 2017). DOI: https://doi.org/10.1177/1556264617704542.
Blell, Mwenza, and M. A. Hunter. "Direct-to-Consumer Genetic Testing's Red Herring: 'Genetic Ancestry' and Personalized Medicine." Frontiers in Medicine 6 (March 2019). DOI: https://doi.org/10.3389/fmed.2019.00048.
Damotte, Vincent, C. Zhao, C. Lin, E. Williams, et al. "Multiple Measures Reveal The Value of Both Race And Geographic Ancestry For Self-Identification." bioRxiv (July 2019). DOI: https://doi.org/10.1101/701698.
Nanibaa' A. Garrison. "Genetic Ancestry Testing with Tribes: Ethics, Identity & Health Implications." Dædalus (March 2018), an open access publication of the American Academy of Arts and Sciences. https://www.amacad.org/publication/genetic-ancestry-testing-tribes-ethics-identity-health-implications.
Horowitz, Adam L., Aliya Saperstein, Jasmine Little, et al. "Consumer (Dis-)Interest in Genetic Ancestry Testing: The Roles of Race, Immigration, and Ancestral Certainty." New Genetics and Society 38, no. 2 (April 2019). DOI https://doi.org/10.1080/14636778.2018.1562327.
Paywalled Article
Rubanovich, C.K., Taitingfong, R., Triplett, C. et al. "Impacts of Personal DNA Ancestry Testing." Journal of Community Genetics 12, 37–52 (2021). DOI: https://doi.org/10.1007/s12687-020-00481-5.
Excerpt from the abstract:
"While 46% of survey responders (N=147) reported their ancestry results as surprising or unexpected, less than 1% (N=3) were distressed by them. Importantly, however, 21% (N=67) reported that their results reshaped their personal identity. Most (81%; N=260) planned to share results with family, and 12% (N=39) intended to share results with a healthcare provider."