"Countries with legalized prostitution are associated with higher human trafficking inflows than countries where prostitution is prohibited. The scale effect of legalizing prostitution, i.e. expansion of the market, outweighs the substitution effect, where legal sex workers are favored over illegal workers. On average, countries with legalized prostitution report a greater incidence of human trafficking inflows."
Whether you hide your patronage from people who know you is a different matter. (The medical system is a good example in this respect: hospitals and other facilities are absolutely not hiding their presence from anyone—quite the opposite, really—but the fact that you visited Doctor Jones to treat your potentially embarrassing medical condition is considered very confidential information.)
Just because the law doesn't mandate confidentiality doesn't mean the customers won't expect it and reliably get it.
If they need a similar law for prostitution, they could pass one (I wouldn't be surprised if one already exists for a sufficiently broad category of "theraputic" services), but I doubt it would be necessary—at a brothel, only someone who verifies ages even needs to see a client's ID (and I suspect they could cover up the name); and as I said, it's strongly against the brothel's interest for there to even be rumors of non-confidentiality. I suspect a law would only move it from 99% privacy to 99.9% or something.
It permits victims of sex trafficking to go to law enforcement without being arrested for prostitution by unsympathetic cops.
I listened to a podcast about some pig-farmer who killed like 49 prostitutes over 10 years back in the 80s-2000s in Vancouver, B.C. the police didn't know the prostitutes were missing because they don't want to be seen, they are hidden so they're easier to just kill and nobody notices... I guess.
It's not easy for me to understand why the legal system attacks the ones it's supposed to help, I mean, makes selling illegal, rather than making only buying illegal.
(In some/many? countries in Europe, it's ok to sell sex, but illegal to buy. So the prostitute can go to the police)
Sex trafficking can still be prosecuted. In general, though, prosecuting the victims of crimes doesn't make it any easier to prosecute those who victimized them.