Well it comes down to statistics. In Sydney, there's now supposedly greater than 20% HIV infection rate amongst gay men. It's quite high, and much higher than the HIV infection rate amongst the general population. This probably isn't the case everywhere, but in Sydney, a randomly selected gay guy is far more likely to be carrying HIV than a randomly selected person from the rest of the population.
In Sydney the HIV infection rate amongst prostitutes is actually very low. However in Hanoi it's supposedly 30% (now this number might be inflated - prostitution is illegal in Vietnam, so the government might be stretching the truth a little to justify policy). One again, this is far higher than the HIV rate amongst the general population. A randomly selected prostitute in Hanoi is far more likely to be carrying HIV than a randomly selected person from the general population.
What's the HIV infection rate amongst gay men in Hanoi? I don't know, but for argument's sake let's say it's lower than the general population. If this were the case, using the HIV statistic alone, it would make sense to accept blood donations from gay men but not prostitutes in Hanoi. But it makes sense to accept blood donations from prostitutes but not gay men in Sydney (one again, based on the HIV statistic alone; there are other statistics that could be used to argue against accepting blood donations from prostitutes in Sydney).
Profiling is imperfect, but in theory it's still a useful like of defence. In reality it won't work so well, as people can lie pretty easily, especially if there's an incentive to doing so (e.g. prostitution is illegal in Vietnam, so a prostitute would be unlikely to list this as their occupation when donating blood). A lot of people also have some basic sense of responsibility, so gay or not a person who knows they're HIV positive is generally unlikely to donate blood (unless they're an arsehole, but then they'd likely lie to pass criteria anyway). Ultimately it's best to just trust no-one and test everything.