apt remove keeps a package’s config files, in case you install it again. Over the years these leftovers pile up, and dpkg -l marks them with rc.
See them first:
dpkg -l | grep '^rc'
apt list '~c'
Both show packages that are removed but still have config files. ~c is the short form of the apt pattern ?config-files, which matches exactly that state.
Then purge them all in one go:
sudo apt -s purge '~c'
sudo apt purge '~c'
Quote the pattern so your shell leaves the tilde alone. This is different from apt autoremove --purge, which deals with unused dependencies that are still installed. The ~c pattern only looks at packages that are already gone.
I like doing this before reinstalling a service from scratch, so the new install doesn’t pick up an old config I forgot about.
Purging deletes your changes to those files for good, and sometimes more: some packages remove their data folders on purge too, like a database package deleting its data directory. Read the list from the simulation and keep a copy of anything in /etc you might want later. There’s no undo apart from your backups.
Further reading: apt-patterns(7) manual page, apt(8) manual page