Things melt because they get really hot. Since the amp was unplugged and unbolted the amp probably short circuited because water got into that area. Should make sure that water is not allowed to accumulate or enter that area so that the new amp won't suffer the same faith as the old amp.
You need to determine which sound system you have, the standard system or the DSP system. Amps can be purchase from BMW re-cyclers, eBay, Craigslist, even on this forum in the for sale section.