I believe some people are just trying to identify with your pain.
Some people just have poor social skills and are just trying to “stay on topic”.
Others do get in a sort of contest about whose experience is worse. This is most definitely annoying. I find it helpful to acknowledge their pain and move on. The acknowledgment is the key.
A lot of the time these people feel like they went through crap and no one cared, no one acknowledged their pain. So when someone brings up their own pain and gets sympathy or even just a good story from it, it brings about their feelings of pain and trauma and hurt. It is a typical psychological response from them not having their needs met.
Just throwing the idea out there that even though sometimes it is quite annoying it’s not always due to someone being a pain in the arse. There are other possibilities. And even when it is annoying it is most likely due to the fact that this person really has been through heck and didn’t get their needs met. Now, there are some just annoying people out there, but it is better to presume they are in the other category.