There are some serious issues with the parameters and water conditions here.
First, nitrates are too high; you want to keep this no higher than 20 ppm, and lower than that is the aim. Nitrates harm fish primarily by weakening them, which in turn causes other issues and stress, and it just keeps compounding. Your first task is to find out if the 40 ppm nitrate is occurring solely within the tank, or if you have nitrates in the source water (tap water). Test the tap water on its own for nitrate. Once you know this, we can discuss options. Nitrates occurring within the tank only is fairly easy to deal with.
The other thing and at this point more serious is the low GH. Mollies are livebearers, and all livebearers evolved in moderately hard water (Central America and Mexico). Their physiology is designed to use minerals, especially calcium, and magnesium, they assimilate fro the water in which they live. Their metabolism willnot function properly in soft water, or in acidic water (pH below 7.0). It doesn't really matter how high the GH and pH are, but right now both are too low and the mollies simply cannot survive long.
As Guppylover mentioned, another issue here is tank size; mollies are not small fish and they will grow to 3-5 inches (females tend to be the larger), some even to six inches. So they need much more space. I mention this because you need to rectify the GH if you intend keeping mollies (or other livebearers), but a larger tank is needed, and any changes you make to harden the water will not be appreciated by any soft water fish you might have. So fixing the molly problem might be making something else problematic.
Nitrite at 0.5 is a concern too...was this tank cycled before the fish were added?