It depends on the program. Many of them clean up, usually with a little checkbox to confirm throwing away your settings, but a lot don't. It might not be 100% of the apps, or even 50% for that matter, but it happens.
On macOS that mechanism is simply impossible if you install the app using the drag&drop method.