The patents on AAC-LC (which is all that really matters when encoding at medium to high bitrates, and that very much applies to the files sold by the iTunes store, too) should have expired by now, given that it dates from 1997, and indeed Fedora has been including an AAC-LC encoder since late 2017.
There's only two ways. Apple Music (streaming) and iTunes Store.
iTunes Match lets you "upload" your library to Apple. It matches your library against Apple's catalog. If they have the song, you get a copy of their version of the song. If it doesn't have a match, they retain your uploaded file.
I have a lot of random local music that isn't on iTunes, and which you can't easily find anymore. For years, I was paranoid about losing my ripped copies of the files, but iTunes Match has preserved them for me, in the cloud, for years now.
The iTunes Store is the "purchase the file" store.
The iTunes Store sells M4A, which is a common open audio format.
The iTunes Store does not, however, sell lossless files, as far as I know. Apple Lossless (ALAC) is only available when streaming from Apple Music.