Comparative population genomics in animals uncovers the determinants of genetic diversity