Tolkien changed the history of "The Hobbit" in the second edition of the book to show the dark power of the One Ring, which it manifests in the trilogy "Lord of the Rings." In the original edition of 1937, Gollum was willing to bet on his ring and give it to Bilbo in case of loss. When Gollum lost, he was disappointed that his ring was gone. He thought he had lost the ring, and as an alternative showed Bilbo out of the dungeon. They parted very friendly.
In the trilogy "The Lord of the Rings" has completely changed the nature of the ring. It ceased to be a useful magical item and artifact was a mighty power, so friendly behavior Gollum in the book "The Hobbit" seemed inexplicable. Tolkien resolved the difficulty by simply rewriting the chapter - now Gollum had no intention to completely abandon the ring and show Bilbo output. In addition, he became much more miserable, and what should be essentially enslaved ring.