Via freedom to coercion: The emergence of costly punishment