|Sthenictis, a fossil mustelid|
In the past, scientists would work this out by examining the physical features of animals, reasoning that those with the greatest similarity were the most likely to be related. By adding in information gleaned from fossils. such as their age and location, and any evolutionary changes they may have undergone, it's possible to get quite a lot of information this way. However, today, it is more common to use molecular and genetic information, seeing how genes and the proteins they produce have changed in subtle, often invisible ways, over the course of time. Taken together with the fossil information, this can reveal many relationships that might otherwise remain obscure.
In the very first attempt at scientific classification of animals, way back in 1735, weasels were grouped together with martens, polecats, and civets as a sort of collective group of small slender mammalian carnivores, although otters and badgers were placed separately. However, it was not until 1817 that the weasel family was formally named by German naturalist Johann Gotthelf Fischer von Waldeheim. That, of course, was still before we understood evolution, and it's hardly surprising that we've moved on since then.