Who prepares it and why
The risk assessment is a duty of the manufacturer of a machine. EU machinery law requires the manufacturer to identify the hazards arising from the machine, estimate the risks and design and build the machine taking the results into account. EN ISO 12100 describes the method.
It is a design tool, not a closing document. If it is written only when the machine is finished, all that remains are guard fences and warning signs – the weakest means.