Prostitution is illegal
It depends how you define ''illegality''. It's not prohibited, but not regulated by law.
people actually go to jail for that in numerous cases
Yes, but (thanks to loophole) only if the authorities can prove that they force or encourage in some way women to have sex with customers.
Actually, many of said agencies (not saying that all of them!) are connected with mobsters and human trafficking.
And even if the police shut down one of them, another ones pops up quickly in their place.
(To moderators: Please merge my messages
I've just remembered some funny, true story I have read about in newspapers few years ago:
A Polish woman returned from Germany, where she earned a hefty amount of money, working as a prostitute (brothels are legal in Germany).
Polish Urząd Skarbowy (tax office) wanted her to pay back taxes, but it caused a huge problem: since prostitution is not regulated by Polish law, it's not a subject to taxation. So she said she won't pay.
I don't know how it ended, though :(.