Since Ubuntu 24.04 the main repositories live in /etc/apt/sources.list.d/ubuntu.sources, not in the old sources.list. The format is different, and so is the way you switch a repository off.
A deb822 file is a set of stanzas with fields, separated by empty lines:
Types: deb
URIs: http://archive.ubuntu.com/ubuntu/
Suites: noble noble-updates noble-backports
Components: main restricted universe multiverse
Signed-By: /usr/share/keyrings/ubuntu-archive-keyring.gpg
Multiple values are separated by spaces, so one stanza covers several suites and components that used to need several lines.
To disable a repository, add one line to its stanza instead of commenting out everything:
Enabled: no
Remove the line or set it to yes to bring it back. After any change, run sudo apt update. I find this cleaner than a file full of # characters, and it’s easy to see in a diff.
Third party repositories can use the same format in their own .sources file, and apt has supported it since version 1.1. Old one-line .list files still work next to it.
Mind the file extension: apt only reads .sources files as deb822 and .list files as one-line format. A deb822 stanza saved as .list gives parse errors on apt update. And don’t remove the empty lines between stanzas, since that’s how apt tells them apart.
Further reading: sources.list(5) manual page