What would stop the cartels from investing in legal storefronts and capturing profits regardless? (This certainly shouldn't be construed as an argument for the morass we have now, just an interesting aside.)
Nothing would stop them, but there would less of an incentive in such business considering the profits wouldn't be as enormous as they are now in the underground market. Profits are huge because the supply is low (and risky) and the demand is high. Legalization, I would think would bring up the supply, after all it would be legal to farm it in mass-production just like tobacco, dropping prices significantly.
Presumably nothing if the money they use to invest is considered legitimate.
Nevertheless, it really seems logical that as a society we should prefer that market competition occurs legally in a open and free market rather than violently in an illegal and black market. The difference between the two types of economic activity is tremendous.
Many of the states that have legalized marijuana require that no part of that trade cross state borders (including growing it, packaging it, investing in it, etc.) (This may be true of all the states that have legalized it, but I'm not sure.)
So the Mexican cartels can neither sell the stuff they grow in Mexico in the states nor own the storefronts legally. Doesn't mean they can't do it illegally (they seem to be good at hiding their illegal activity, after all) but they can't go legit.
My assertion is that, with the backing of enterprises raking in 12 figures annually, it's within their operational capability to obtain all the necessary parts to do exactly that.
To be fair, I think it's entirely possible that there are enough savvy businessmen in the cartel to realize that it's wisest to prepare for any number of likely outcomes of legalization. Just imagine Goldman Sachs with more beheadings.