Your Mac can import music, store it, convert its formats, send it to other devices, and play it back. The iTunes program comes with the Mac and is its main tool for managing music. the See the Using iTunes article for specific how-tos.
You can buy music tracks from the iTunes Store over the Internet. These tracks are usable only on one computer unless you pay extra for "unlocked" tracks. I have not bought any music from the iTunes Store because of this Digital Rights Management (DRM) encryption, because if some accident erases my crypto keys, or Apple changes its rules, all the music I bought this way could become inaccessible.
You can also buy music online from Amazon; their tracks are not locked or encrypted. I have bought about 20 albums this way, and they work fine.
Suppose you have a bunch of music on vinyl records or cassette tapes, and you want to digitize it and be able to listen to it on the Mac, iPod, etc. You can pay to have this conversion done. I used cassettes2cds.com, now called Reclaim Media, to convert 43 cassette tapes to CDs. They did a fine job. They also do LPs and I may try this out.
It is perfectly legal (in the US) to make a backup copy of media you have purchased. (Selling copies would not be legal.)
If you want to do it yourself, I found a good article by Matt Neuburg on TidBits.com that explains the basic steps. To do the analog to digital conversion, you want a hardware box that attaches to your Mac: the built-in conversion in Macs and PCs is "poor."
I bought an ARTcessories USB Phono Plus v2 and connected it between my turntable and a Mac Mini. On the Mini I use the free software Audacity to capture the USB audio stream from my old B+O turntable, clean up the data (removing clicks and surface noise), and split the input into separate MP3 files I can put into iTunes. (I use the Silence Finder plugin, delete spurious markers, and then type in the track name and artist for each track.) This can be time consuming, since I have to convert the audio at regular speed, and then the post processing and track name input takes more time. Audacity is quirky to use but adequate for my purpose, since the old records I am converting were not super high fidelity to begin with. It takes me about 2 hours per record, though I can multi-task while the record is playing. (Audacity 2.1.2 works OK with El Capitan 10.11.5 for me.) Once the music is in iTunes I can listen to it on the Mac, or burn MP3 CDs for the car, or burn audio format CDs for portable players.
A few years ago, a friend wrote: "I have found that it is very hard to impossible to listen to music on Amazon or other similar sites. It always says I have to install a plug in and we don't have success doing that either. I am sure we are doing something wrong, but on an IBM style computer, you just click and listen."
I had the same problem. Firefox recommended Flip4Mac, which hooks into QuickTime on the Mac. You can download it from Telestream -- it costs $5.95 for the Mavericks version. I downloaded the Flip4Mac component and installed it, and then I could play files in Microsoft format. Since I moved to Mavericks I stopped using it. (Amazon changed its song previews to use Flash, which has its own issues but is more mainstream. Most music sites now seem to use Flash.)