How can "Prostitution be illegal" but "Buying sex be legal"

I was looking at https://en.wikipedia.org/wiki/Prostitution_in_Asia and in places like Thailand and Philippines "Prostitution is illegal" but "Buying sex" is legal. How can this be both should be illegal or legal right? Also in some places "Prostitution is legal" but "Brothels illegal", I guess this means that a woman can sell herself on the internet but can't operate in a brothel?