Publishing it has several reasons! People like finding others who are like-minded, so a sense of community or finding friends who might be able to understand your preferences or even your trauma can be one reason. Someone publishing their works might not even be looking to directly interact with others, but might hope they resonate with their work and feel seen. Another, less in depth reason is simply approval. Some people create fan works because they like to get a response, be it a work that came from a place of trauma or a work from a place of 'i just want to get off on this'. Some people just like sharing what they create with no intention of getting feedback, they want to write or draw something and just put it out into the world for people to view and then they don't really think about it again! It really just depends on the person.
Myself as an example again, I tend to post taboo works because I want people to know they have a right to create and share them, and also because I just want people to enjoy and possibly engage with it! I don't feel the need to hide that I make these works because I don't find them shameful, regardless of if I'm venting my own issues or writing/drawing them for purely sexual reasons.
RPF is a tricky issue in my opinion, personally I don't enjoy it but as long as it is contained within it's tags, isn't shown to the people it depicts without their consent, and the actual people it's about werent mistreated to create said work [ex. Actual pedophilia hidden behind the guise of RPF], then it at the very least has the right to exist within those spaces, like AO3 having designated tags for it. It really just boils down to "did a real person get hurt to create this work?", and if the answer is no I mostly ignore it in regards to RPF
When it crosses the threshold of a fictional scenario into reality [ex. Actual CSEM or snuff], it no longer becomes a discussion of fandom spaces or fiction vs reality or even whether it's coping or not, as real people are hurt, at that point it's just abuse and exploitation
Also ocf! I don't mind discussing things like this :]