It all depends on the context. If we are talking about kids and we can tell stories without competing then nothing needs to be done. Again, if someone is talking about their accomplishments for some purpose other than to make someone else feel bad or for self-aggrandizement, then there’s no problem.
If people are doing it not to share, but to try to make themselves look better, or to rub it in your face either knowingly or unknowingly (some people are totally oblivious), then other measures are called for, and they depend on what kind of situation you are in. Family and friends are a little different from strangers and acquaintances.
I think the best strategy is to find some way to excuse yourself—such as having to use the facilities or having some chore you have to do.
I wouldn’t want to slap the person in the face with their behavior, but perhaps I’m too nice. Then again, there are somewhat more assertive things to say, such as, “Excuse me, but you’ve been talking a lot about your wonderful children, and I’d like a chance to talk about mine.” Or you could say, “Wow! You’ve been doing a lot. Would you like to hear about what I’ve been up to?”
Or, if you are feeling diminished, you might just give them their victory and retreat from the field of battle. “Wow! You’ve accomplished a lot. I’m jealous, to tell you the truth. I don’t have anything like that to talk about. Well, I could tell you about the time I was counting spots in the ceiling while I was waiting for the doctor to come in.” You give them their victory and make fun of them for caring all at the same time, and practically force them to say, “Uh, I’d love to hear about that, but right now I’ve got to go bore someone else go to the ladies.”