a package"foo" might depend on another package "bar".
this means that you cannot install "foo" without having "bar" installed.
the task of a package-manager is to make sure, that the package "bar" is installed if the user requests to install "foo".
now modern package-managers will also keep a record of each package, whether it was installed manually (because the user requested this package to be installed) or automatically (because the user requested another package to be installed, which in turn required this package).
if the user uninstalls package "foo", the system might discover that "bar" is no longer needed on the system (the only reason to have "bar" on the system was that "foo" required it; now that "foo" is to go away, "bar" should probably go away too).
this should guarantee that your system does not get overly bloated with packages you don't need.
sometimes things are a bit more complex.
imagine "foo" depends on "bar"...but then a new and updated version of "foo" depends on "baz" (and doesn't need to old "bar" at all).
what happens when you upgrade "foo"? it will install the new "baz" package and it will remove the automatically installed "bar" package.