I’ve heard that Microsoft is working for a package manager on windows, or they already made one, or something like that.
A package manager is basically a program that keeps track of what is installed in your system, handle dependencies, and be able to remove dependencies that are no longer used by anything on the system. Package managers have been around for many years on Linux systems, but I’m not familiar enough with windows to know how possible it is now.
Apart from that, it would be really difficult to deal with this issue. You could hope a game comes with an uninstaller that cleans everything, but its risky removing a dependency, if another program might be using it too.