Escorts are legal. Their official service is to follow you around so you can flaunt them off and have a companion.
Having sex with an escort is legal. There are, however, many strings attached.
The first is that you cannot ask for an exchange of sex for money. In most cases you aren't even allowed to specify what you want to do. Most escorts already have a package deal that they come with and there are only specific acts that they will perform. If at any time a sexual favor is discussed, then it's considered solicitation and she's now (il)legally acting as a prostitute.
Of course, this is all legalese. There are special codes and such that escorts use so that they can, basically, be prostitutes. It's only legal because, as far as business and vice law are concerned, there isn't any solicitation going on. If you have sex with an escort then it's no different than if you picked up a girl at a club, took her for coffee afterward, and had sex.