You could check /etc/apt/sources.list file and *.list and *.sources files in /etc/apt/sources.list.d/ for any non-Ubuntu repositories. Disable/remove the repositories that you want to. In recent Ubuntu releases the default Ubuntu repositories are defined in /etc/apt/sources.list.d/ubuntu.sources so you don't want to remove that. I tried sudo add-apt-repository -r in removing the JOSM repository in Ubuntu 24.04 and it did not work well in my experience. Maybe a newer version of it works better. Anyway, but you can manually remove the files or rename them to have e.g. .save filename postfix or disable some repository in a file.
Thereafter you just need to sync packages to match the remaining repository definitions. I made a script called apt-downgrade to do the job. It is currently available in my Launchpad git repository. Unfortunately browsing the code does not work currently, but you can clone the repository to download and tryby git using a command given in the repository page. It creates a directory containing the script. RunCopy the script to /usr/local/bin/ and run apt-downgrade -h forfor help.