BGMs can be either .midi, .wav or .mp3. Midi is a special kind of filetype not unlike sheet music in the real world. It does not actually contain any sound, but rather a series of tracks with the notes its instruments would play, and the computer generates the sounds when you play the file. Because of this unique difference, .midi files can be a huge amount smaller than common music files, often as small as a few kilobytes compared to several megabytes for most .mp3s.
If you do decide to edit or even compose your own .midis, you could try a bunch of programs. One free program is Anvil Studio, which is pretty basic but will get the job done, but there's a bunch of commercial products such as Fruity Loops that offer much more advanced functionality for a price. Hope this helps!