:salamext:
There is also another hadith where a man came to the Messenger of Allaah (sal Allaahu alayhi waSalam) and kept mentioning that he's commited zina [fornication], the Messenger of Allaah turned away a few times but he persisted. The Messenger of Allaah was giving him an excuse to go away and repent [and insha'Allaah his sins would be forgiven] but because he was making the matter public, then the punishment had to be applied.
Otherwise if the punishment isn't applied then people might do it all the time without the fear of punishment in this world. But if they have the punishment in this world - insha'Allaah they are saved from the punishment of the afterlife.
If they keep their sin quiet and don't mention it to others, then repent - insha'Allaah if they are sincere Allaah will forgive them and they won't be punished in the hereafter insha'Allaah. And Allaah azawajal knows best.
We know that within the life of the Messenger of Allaah people did still drink alcohol, commit fornication etc. but most of the time it was done in secret. Because it was done in secret, there weren't much witnesses to the crime - so the people couldn't be found guilty, and others wouldn't know about it.
Now islaam does prohibit these sins, yet it is hated in islaam even more that the sin is done publicly. If it's done publicly and people find out that its widespread, they think that if the others can do it - why can't I? Which leads to more immorality in the muslim state.