I've always kind of wondered about this myself.
There's 3 possible options I've thought of, though I'm not sure which is generally used, or if I'm way off track...
1) "MIDI". Console systems such as the SNES or N64 had their own soundcard in the system which generated sounds to be played on something similar to midi tracks. What probably happened is these signals are simply repeated at set points, allowing for an infinitely long loop of music.
2) The audio is cut and timed with extreme precision so that the original audio file is precisely long enough that when coded to perform a simple "loop" by playing the song again after finishing, it sounds like there is no gap in the music. I've always thought this to be a terrible way to do things, and I don't know if it's used, but it has too many flaws. If the song loads again too slow it won't be on time, and if it's not cut at the precise millisecond AND at a point where there won't cause any strange audio side effects, the beat of the song won't carry through. Lastly, most songs tend to have a short intro, and then a looping part of a song. Seems like more work than necessary to create 2 separate sections (ie. intro and looped segment)
3) The song is kept in memory constantly until it needs to stop. Then when the song is nearing the end, it is played again while the other instance of it finishes playing. This would also be hard to time, and it just seems inefficient.
So basically, I don't know how it's done in professional games. Audio glitches in regards to looped music in those is almost nonexistent or very subtle.