So my parents are actually microbiologists, and my brother and I had an army of rubber ducks/fish/etc. for the bathtub as kids. There are a couple tricks to making sure they don't get moldy:
Squeeze all the water out of the toy at the end of bath time. My parents would make us kids do this ourselves to instill "clean up time" and "taking care of your shit," and then they would do an extra, just-in-case squeeze with grownup dexterity on anything they though we might not be able to squeeze effectively. If needed, give the toy a good whack up-and-down to encourage water from the extremities to move toward the hole.
If a toy can be disassembled, do that at the end of every bath.
Any cloth or foam toys should be hung up to dry so that air can circulate around all sides.
Large toys (like a water-safe baby doll) should be oriented with the hole facing down to let water drip out.
Try to have the toys live somewhere well-ventilated in-between baths (mesh bag, open basket with holes, etc.).
Check toys every so often for mold. Give them a good sniff and hold them up to a bright light. If they smell weird or have any dark patches that can't be accounted for by the toy's inherent design, they are probably moldy and should be thrown away.
Beware of prime suspects: Toys with odd or angular shapes, large toys with too-small holes or just 1 hole, toys with rubber or plastic that is so stiff an adult cannot easily squeeze it.
Give your kids cups, bowls, colanders/sieves, and ladles in the bath. This doesn't really stop mold, but it lets them practice drinking and fine motor skills without too much mess, uses stuff you already have, and may distract them from slurping out of the tub toys. Yes, it's fine if they drink a little tub water.
I know people will say their kid will be heartbroken if they have to toss a beloved-but-moldy toy. Bearing in mind that I'm not a child development expert, I would say it can be an opportunity to explore the concepts of change, loss, coping with undesirable situations, and caring for the health, safety, and cleanliness of ourselves and those around us in a low-stakes way. I absolutely remember a few tub toys having to go, and while I was sad, I was not traumatized by it in the least.
Try framing it as "[Toy] is moldy and icky inside. It is not the kind of icky we can clean. If we keep using [toy], it can make us sick, so the best choice we can make is to say goodbye to [toy.]" Maybe give them a day to say goodbye/grieve, thank the toy for all the good times, etc., before it goes in the trash (preferably in a bin the kids can't access).
Also, hot tip, if any of the shitty paint on your rubber animals fades over time, just Sharpie the design back on. The Sharpie will eventually wear off, too, but you can just do it over again. My father kept one of our rubber duck's eyes on this way for about a decade for the low, low price of like $0.005 in ink.