First, let’s start with the lossless formats, FLAC (Free Lossless Audio Codec) and ALAC (Apple Lossless Audio Codec), designed for high fidelity sound. These two formats are pretty much equal in terms of sound quality. The only difference comes in terms of device compatibility: ALAC is an Apple-specific format which can be played by iTunes. Of course, if you wish to play FLAC on Mac, there’s certainly a way - apps such as the Elmedia Player can do just that.
Next, on to the lossy formats. Advanced Audio Coding (AAC) is an audio coding standard for lossy digital audio compression. It provides lower sound quality than the lossless FLAC and ALAC above. Still, AAC actually offers better quality than MP3 at the same bitrate.
Other lossy formats include MP3 and WMA. MP3 is probably the most common one which needs no introduction, while WMA is not so widely supported (i.e. it is not compatible with iTunes). If you wish to play WMA on Mac, you need an all-around good player which supports the WMA file type.
M4A, another popular Apple file type, is usually coded with AAC, making it a lossy format. However, M4A is actually a container. This means you can choose from several different audio codecs depending on your needs. For example, if you use the ALAC audio codec for M4A, it will preserve all of the detail, while still keeping file sizes smaller. Again, to play this file type on both macOS and Windows, you can use a versatile M4A player such as Elmedia - it can open an extensive range of files.