Your Mac can import music, store it, convert its formats, send it to other devices, and play it back. The Music program comes with the Mac and is its main tool for managing music. the See the Using Music 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 Music. (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 Music I can listen to it on the Mac, or burn MP3 CDs for the car, or burn audio format CDs for portable players.