You're not a bad friend OP.
I'm a bit like this - I'm way too open with my own life, so sometimes I miss the boundaries of what is appropriate to talk about with regards to other people's lives.
I too will talk to my friends who live abroad about issues that might be considered 'secret' closer to home. This is in no way to gossip, but like you said, to share someone else's story to try and help a friend, or to offload etc.
I have found myself getting a lot better at keeping stuff in though - my DP is very private, but I used to share stuff about him to my parents, sister etc. However, he is currently going through quite a major change in his work life, something that will be quite exciting if it comes off. I did wonder how I would keep this a secret from my family - but you know what, I havent felt a single urge to talk about it with anyone. I think it's because DP and I keep our private talk between us, and then I forget about it when I'm with others. It just doesn't occur to me to talk about it.
I have also found myself in great admiration for a friend who is the epitome of discreet. Her powers of discretion are astounding, and I really respect her for it, and vowed to be a bit more like her.
So maybe you could try just partitioning off your mind - what's talked about with one friend, stays with that friend. Then forget it when you're with other friends.
Well done OP for recognizing it, you will be a better friend for it.