There is also the theory that it serves as a reenactment of one’s own abuse. Trying to find peace and return to safety by replaying the scene, this time not as helpless victim but perpetrator: in control.
Victims of sexual abuse thus often are haunted by “fantasies” of abuse but avoiding the victim position; the trap is to identify with the fantasies. All too often, they’ve been told it is their fault, they wanted it etc, so the imagined replay “proves the original perpetrator right”.
The only way to break the circle seems to be to fully go into the fantasy and process the victim position, with support of a well-meaning presence (typically a therapist but in another reality it could be friends or family).