>I'm using Lightroom Classic latest version (10.2), does that change anything you said?
No it is the same in 10.2. I had just answered a question on Lightroom 6 and still had that in mind. My mistake. The answer is exactly the same
>Is it correct that all edits to a file are stored in the catalog in all cases?
Yes. Lightroom Classic stores all edits in the catalog file. When you use xmp files, those are just a backup of the edits. The main storage is in the catalog.
>You are saying that if the "automatically write changes into xmp" is turned off, the changes will be written only to the catalog, and not to either the DNG or xmp file. Is that a correct understanding?
Yes that is correct. The setting is only there to provide a backup of the develop settings and other metadata. They are always stored in the catalog
>If "automatically write changes into xmp" is turned on, then the edits will be stored in the DNG file, the XMP file, and the catalog. Is that a correct understanding?
Yes. With the caveat that for dng files no xmp file will be created. The xmp data is stored inside the dng file. You only get xmp files for proprietary raw files such as NEF for nikon cameras. In all cases, all settings are stored in the catalog. You only should do the automatic xmp writing if you need those as a backup. In most cases you shouldn't do this as it does slow down editing.