A dog DNA test genotypes your dog's sample at many points across the genome and compares the patterns against the company's reference database of dogs with known ancestry. The breed percentages you get back are the best statistical explanation of your dog's DNA given that reference data.
That's a genuinely powerful method - and it's also why the honest answer to 'how accurate is it?' is 'it depends on the database.' A breed that's well represented in the reference panel gets matched confidently; ancestry the database has seen less of gets estimated more loosely.

