Origins and functional evolution of Y chromosomes across mammals