Installing the "same" package doesn't overwrite previous versions -- all packages are persistent -- so dependencies continue to work.
It is the mutation of packages, silently breaking API and ABI compatibility, that is the bane of distro management. Nix is a great attempt to address this.