Nothing wrong with using buckets, easy to clean, easy to store, almost unbreakable, and come with a handle. If possible, it's best to leave the lid on at all times, until ready to package. If you need to take a sample you can suck some out through the airlock hole in the lid, using a piece of skinny tubing with or without a large syringe.
If you need to dry hop, or add other stuff, you'll have little choice but to remove the lid. This will blow off all the protective CO2 from the headspace, and fill it with air. That air can cause infections but much more likely, oxidation of the beer. There really is no simple answer to remedy that, except for racking into a carboy and leave very little headspace, 1-2" under the bung, or rack to a keg that can be purged with CO2. If you have CO2 available, the bucket's headspace can be flushed with it, to rid of most air (oxygen).
Before removing the lid, the whole lid area should be clean and sanitized. Mop around with a small washcloth drenched in Starsan and/or use a spray bottle with Starsan. Pay special attention to the rim area. It's difficult to sanitize too much, but easy to forget a small patch or area. After removing the lid, I always wipe the bucket rim with said washcloth.
Revisiting the "mold:"
Rethinking my earlier statement about it being mold, I would be very surprised to see mold develop that fast. Possibly it's foam from the yeast. That beer may not be quite done yet, or it's simply outgassing. It's probably safe, so you can relax about that. The large headspace is still a bit of an issue, nothing you can do about that now.
For next time, leave that beer in the bucket until ready to bottle/keg. Get another bucket to stagger your fermentations.