Please please please don't put a molly in a breeding trap. Ever. For any reason.
The babies weren't born dead, they were miscarried. Just as can happen with humans, if the molly is stressed beyond a certain point, she goes into labour, and the babies come out whether they are ready for independent life or not. Putting a female molly in a trap is cruel. She gets terribly stressed, and then miscarries. What you report is sadly very, very common.
If you're worried about other fish eating the babies, either remove the female molly to another tank (even a plain 10 gallon tank with a heater and an air-powered filter will do) or else fill the top of the tank with floating plants. Hornwort is cheap, easy to obtain, and works very well. Failing that, standard issue goldfish pond Canadian pondweed will do the trick, too. Floating plants give the babies somewhere to hide for a few hours or days until you can rescue them.
Do read the pinned topics on raising baby fish. You can use a trap for the first 2-4 weeks, but after that, you will need another aquarium. Trust me: a tank for raising baby fish is one of the best investments you can make, and the amount of pleasure you will have in raising a full brood to sellable size easily offsets the expense! So please do try again, and good luck!
Cheers,
Neale