Sometimes the job calls for a door that swings freely, sometimes a lock is better, and very often the best is a fastening mechanism that uses a spring to cushion the force of impact. A wooden door is resilient, but if it closes with force, it makes quite a bit of racket that might also damage other types of fasteners. An industry solution is the soft close hinge. These dandies have a tab with a spring. It takes a bit of a push to close the door, but it opens with a spring, and the device is a reliable safeguard.
Consider a door that might be closed shut by a soft breeze. It might be a nuisance if a small shift can lock a door in place. This is prevented by a spring as much as reducing the force of impact. While the mechanism is a bit more complex than a lock, the benefits do add up over the years. The hinge lasts.