When CDs first arrived on the scene, mid 80s, some [very few] albums were separately mixed/mastered for vinyl & CD/tape. Partly this was to be able to take advantage of the new, lower noise floor & higher dynamic range than the average consumer's playback system. Partly it was a marketing gimmick, to get people to buy both ;)
As people bought into this new format, there was a great rush as all the record companies hurried to cash in, by re-releasing their entire back catalogue. This was so people would re-buy albums they already loved in this 'new, clean' format. They did, in their droves. It was one of the most successful 're-branding' exercises of all time.
Unfortunately, in this rush, many digital conversions were done from whatever tapes the company could find quickest. They rarely took the time to go back to the actual original masters or even mixes, to process them cleanly.
This resulted in a whole slew of re-releases being done from the EQ masters [made for cutting to vinyl]. The trouble with an EQ master is there used to be a constant fight between mastering engineer & cutting engineer. One would believe that you always lost some 'top' in a cut, so they mastered brighter than necessary. This forced the cutting engineer to re-EQ it before it could be cut, without being harsh & trebly.
…and so the myth persevered. ;)
The result - CDs from these EQ masters were often truly horrible to listen to; far worse than the original vinyl. This also helped preserve the myth that "vinyl is warmer".
We move up another decade. Masters are now made on digital, for digital. CDs are 16-bit 44.1kHz, so masters were made at 16-bit, 44.1kHz & everybody was happy - well, as happy as people ever get.
Another decade & the compressed audio file is starting to become prominent. Apple led the field on this with the original iTunes Store & others followed. Apple didn't like what mp3 did to files at lower bit-rates, so they decided to use AAC instead. Personally, I think this was a good move… and also a bad move. Macs could use AAC natively. Windows needed extra codecs & apps specifically designed to be able to read them.
This led to an imbalance where mp3s held their ground far more than they really should have, because at the time, 80% of the consumer world used Windows.
Right, so AAC is inherently 'better' than mp3, but people want more.
Along came streaming - but people had 1mbps connections so the bar was set low, 128kbps mp3s became the norm.
As internet speeds got faster, higher bandwidths were possible, bringing 256 & 320kbps files to the fore.
Then as people got 'wiser' [a dubious accolade in reality] they discovered FLAC was truly lossless.
So, for the past 10 years or so, everybody feeling 'clever' has got their pirated flac files from usenet or torrents or wherever else…
without realising that these flacs were not released by the record companies or anyone official. They were made by the posters to usenet/torrent. They had no credible source at all. They may have come from the CD, but which CD, one from the mid-80s, or a new one? Did they rip it to mp3 first, then convert to flac? [Yes, this kind of stupidity happens a lot.]
This really, has led to flac being an 'untrusted format'. The few tracks actually released as flac compared to the number out there means in all chance you'll get a 'bad' copy 8 out of 10 times.
While all that was going on, record companies, taking advantage of faster bandwidth & faster computing, started making their masters at first 24-bit, 44.1kHz, then moved up to 24-bit, 48KHz. [48 used to be only used for movie soundtracks & early computer audio converters were relatively poor at downsampling 48 to 44.1, but that distinction is going away now.] Some are even mastering at up to 32-bit, 192KHz. This is very future-proof but almost no-one owns equipment, or ears, capable of telling the difference. The other problem for consumers is that 32-bit/192 is about 23MB a minute. That's going to fill your skinny little 128GB SSD in no time at all.
…and this 'being able to tell the difference' is where we arrive today. Very few people have the ears or the gear to tell the difference between a high bit-rate AAC and the original master. A 32-bit master has a theoretical noise floor so low you could only test it in a scientific anechoic chamber.
As the original masters are now delivered straight to the streaming companies/online stores [or intermediaries whose job it is to ensure they conform to data standards], then the version you get from them is one conversion down from that master.
That beats hands down anything you could steal from the interwebs in flac - as you don't know what you're going to get.
So… to finally get around to answering your question;)
As a high quality AAC file is just one single conversion down from the original masters, you're really not going to get anything better. The stuff you buy [not necessarily just stream] from such as iTunes/Apple Music & other high reputation companies is higher quality than almost any other source except professional, or the occasional 'high quality streaming company'. As most people don't have the ear or the gear to differentiate [no matter what they believe, really] then that's as good as it gets.
So, forget flac… get aac from source.
I do have equally opinionated, rambling answers on other related aspects of "the HiFi experience" covering slightly different topics & angles on similar themes. Have a look if you like…
Is there deliberate marketing that tries to persuade people to prefer vinyl records over CDs?
Standard vinyl vs Audiophile/Weighted vinyl - What's the difference?
If possible, how could mastering engineers allow for stereo bass on vinyl?
…and, btw, my background is as an audio engineer of 40 years' experience, originally in the 'music biz' itself, now retired.