The British required regular venereal disease checks for the prostitutes. The Chaplain-General discovered this, and closed the brothels. General Montgomery closed the ones in Cairo, and in northwest Europe after D-Day. This did not prevent soldiers from visiting prostitutes. It only prevented the Army from regulating them.
Legalization helps governments regulate the activity.
Prostitution is legal in Nevada, but patrons must use condoms. Legalization would put the white slavers and pimps out of business. It would destroy their ability to control, exploit, and abuse women. There's a cheerful thought. I'm sure the Romans were very cheerful after Zama, too.