Evolution works on the level of the reproducing organism, i.e. the individual.
Google group selection if you'd like to go down a deep rabbit hole but the upshot is, if pro-social behavior did not confer and individual advantage, the individuals who lose the trait would outcompete their conspecifics and the pro-social trait would not be fixed in the population.
This is why you usually see additional stabilizing mechanism(s) to suppress free-loading, in addition to the pro-social traits themselves, even in very simple examples of pro-social traits such as bacteria collaboratively creating biofilms.
The genes coding for the biofilms are usually coded on transmissible plasmids, making it possible for one individual to re-infect another that has lost it.
You might consider the justice system, police etc. as analogous to that.
So yes, in the case where you're part of a functioning society and free-loading on the pro-social behavior of others, that is temporarily beneficial to you - until the stabilizing mechanisms kick in.
I'm not saying in practice you can never get away with anything, of course you can. But on average you can't, we wouldn't be a social species otherwise.
In your Durkheimian analogy, sociopaths are cancer and while the body usually handles one off rogue cells, it often fails when tumors and eventually metastasis develop.