The reason why the federal government is able to outlaw prostitution is because the Constitution gives Congress the power to regulate interstate commerce. That includes making some forms of interstate commerce illegal. Such as prostitution.
Now I say this despite supporting the legalization of prostitution. The criminalization of prostitution is constitutional. However, despite that it's a bad idea to do so. It's much better and safer and healthier to regulate it - which Congress can do since it's constitutional for them to regulate interstate commerce.