Why does the number of genes per Mb of DNA vary between organisms?

At the risk of sounding facile - because that is the beauty of the randomness of evolution. Genes are on the whole highly conserved between mammalian species. Their arrangement on the chromosomes and on which chromosomes varies enormously between species again due to the randomness of evolution over many millions of years. The regions of DNA between genes are very variable and are often totally different even in closely related species. Put all that together and it is not surprising that the number of genes per Mb of DNA vary between organisms.