Hmm...that doesn't seem to be a fair analogy, though. It's not just that Apple is providing the OS that runs the software, they're actually distributing it. A better analogy might be Walmart allowing anyone to come into their stores and put stuff on their shelves to be sold on their behalf. I doubt that Walmart would be legally safe once drug dealers, prostitutes, and illegal arms dealers starting piling their wares in their stores.
You could be right. The only way to be certain of removing legal liability would be to allow people to install software through other means than the app store. Having the an app store as a kind of 'premium/safe' zone makes good sense - making it compulsory is the problem.
Apple would be fine, just as a web hosting company is fine if someone puts illegal content up. They'd have to make it clear that they are not the content producer and respond quickly when a legal complaint is received but it's not as if this is uncharted legal territory.
I'd imagine not any more than Microsoft is held liable when a crime is committed by a Windows user.