I'm not in favor of beastiality either. And that doesn't mean I want to control the sex lives of others. There is a valid public health issue involving sex acts with dead things and animals; so I have no issue with either being illegal.
There are valid public health issues with butt sex too. Many of them. HIV being the worst epidemic next to heroin in the US. Gay males spread more HIV than any other demographic.
So your keen legal deduction falls flat on its face.
Despite all the dangers of butt sex it is still legal. Since it is legal, why is necrophilia illegal?
Well, we can take a couple of different whacks at this.
1. The corpse is a dead person who is not able to consent to sex; hence any sex with said dead person is rape.
2. The corpse is an inanimate object now belonging to the heirs of the deceased. So, unless the heirs consent to the sex act, it is a violation of their property rights.