The most basic answer is, standards are generally voluntary and regulations (which include directives, ordinances and anything published by a government body) are mandatory.
Regulations usually details general expectations/requirements (what) and standards usually details application of those (how) or more detailed requirements related to the general expectations requirements.
A simple example, EU regulations are based on the concept of essential requirements, which are high level expectations. One essential requirement (in 12.6. Protection against electrical risks) is that "Devices must be designed and manufactured in such a way as to avoid, as far as possible, the risk of
accidental electric shocks during normal use and in single fault condition, provided the devices are installed correctly".
This essential requirement (as most of the others) is so generic that it's not easy to comply with. Anyway, you can comply with any good engineering solution that does fulfill the requirement.
One way to comply is to comply with the more detailed technical requirements of IEC/EN 60601. More specifically, you would need to comply with 8 * Protection against electrical HAZARDS from ME EQUIPMENT .
So, what the standard does in this case is to clarify, in a more explicitly way, how to comply with the more generic essential requirements.
For more on the link between directives and standards, please read the the
'Blue Guide' on the implementation of EU product rules.