I noticed a valve leak too late and now part of the vanity has built up some mold. I would like to avoid replacing the entire thing obviously. So I would like to understand how (un)safe it is to keep it as is or is there a way to somehow fix it without replacing the vanity.
If the particle board is stable I would suggest spraying the affected areas down with hydrogen peroxide. The hydrogen peroxide will kill mold and not smell as bad as using bleach. (Bleach will also kill the Mold but may cause more damage than peroxide.) After you are sure the mold is gone if the wood is stable it should be ok. Left untreated this could cause a health risk.
Your number one concern should be to thoroughly dry all wet materials. Understand that many materials may be wet that you are unaware of. For example, by looking at the photo, I would presume that you have substantial moisture under and behind the vanity. This moisture has probably affected your wall and floor systems to some degree. If you do not dry all materials thoroughly, mold and rot could continue to be an issue.
Your second concern is known, existing mold. You should not be concerned about whether the mold is "alive" or "dead". Rather, you should be concerned about whether the mold is there or not (and whether moisture is still present and could support continued mold growth). Your goal should be to get rid of the mold. If you are concerned about the immediate health risks of the mold, use PPE while doing this. If the mold is isolated to the visible areas of damage in the photo I would recommend using a rag dampened with a mild detergent and wiping the mold off of the surface. If you are not satisfied with those results, use a wire or nylon brush to brush the moldy surface and then repeat the wipe process.
Note that mold is hydrophobic, meaning water and water solutions are repelled by mold. Spraying chemicals such as bleach or hydrogen peroxide on the mold will do little good. Again, your goal should not be to "kill" the mold.
Finally, if you are satisfied that the vanity is structurally sound and that there is no further issue of moisture or mold behind or under the vanity, your only concern is cosmetic.