Banks himself answered this question in a 5-minute BBC interview:
I blame my uncles; I put The Wasp Factory in, the very first book what I got published and it was "Iain M. Banks" on it, the mainstream novel. And we took it out because my editor thought it looked a bit fussy. And also because he thought people might get confused with the fictitious bad romantic novelist from the Wodehouse novels Rosie M. Banks. So out it came, I wasn't bothered in the least, and then later on, a few months later, I got what I can only describe as avuncular disapproval. Couple of my uncles came up and said "What you take the 'M' out your name for? Are you ashamed of the 'M' I guess? Or what?" For that is how we speak in Fife.
And so I said I'd put it back in. I couldn't put back in sort of gratuitously for the next mainstream novels, so I thought when we started doing the science fiction I'll put it back in. And it actually looks kind of slightly more American somehow. I was thinking of being "Iain M. Banks the Third" at one point, you know, because it's a kind of trans-Atlantic phenomenon, science fiction so it seems more fitting. So that's how the 'M' got put back in.
(Emphasis mine, and any transcription errors likewise.)