As you say, LEGO is very tight with legal issues, so if custom molding was entirely illegal, it's likely we wouldn't see such companies, or maybe in unreachable countries only.
Now, LEGO may be tight with legal issues, but on the other hand they know how to be benevolent when it benefits them. (Consider the openness around the various Mindstorms systems, for example.)
The key here is that LEGO is very protective of its own brand and image, but as long as you don't infringe on that, you're most likely to be OK. In the case of custom molding, it means you can't make any part that LEGO makes or has made itself, and of course you can't pretend it's LEGO at all.
And then you have to hope that LEGO doesn't want to copy you, but even there they can play nice if they feel it's best for them. For an example, take the development of the Emerald Night train. When LEGO started thinking about that, they didn't produce big wheels; but one of the fans who participated in a workshop brought Big Ben Bricks train wheels with him, and by showing LEGO the great models they could build with them, them managed to have LEGO change its position and produce some larger wheels.
Whether LEGO had talks with Big Ben Bricks, or what could have been discussed in these talks, is unknown; but you can notice that Big Ben Bricks still exists eventhough LEGO knows about them. Moreover, LEGO doesn't produce all sizes that BBB does, and even then in limited sets and quantities only (always 4 regulars and 2 blinds together), so that it's likely LEGO tries not to impede too much on BBB.
I a way, I think LEGO is very conscious that these companies fill a gap that they themselves can't, or don't want. As such, as long as these companies play nice, LEGO knows better than to go after them.