"I used to be X, too," statements are so common that I don't think they can be explained by a single motive.
At least some of these people believe they have experienced what you're experiencing and believe they've overcome it. They're trying to tell you not to give up hope. People do overcome things, after all. Whether or not their experience was like your experience is impossible to say, but most of the time I suspect there is a difference of degree, which produces a difference in outcome, between people who outgrow something and people who never outgrow something. I suspect that most people who have been anxious or depressed since childhood do not outgrow it and most of the people who have outgrown something like this have acquired it later, say, at puberty or midlife. I think a lot of it depends on whether or not a person has a "normal" they can return to; if you have never been normal, you can't go back to being normal; it's very hard to construct "normal" responses to things you've never experienced normally.
When people say, "I used to hate my body, too, but then I learned to accept it," I can say with about 99% certainty they have no idea what my experience is like. And I suspect most of the people who say "I used to be shy, too," have no real idea what most of the people here actually experience. The magnitude of an experience can change the quality of the experience significantly; some of the things you drop in the water will float, and some of them will sink, which is why "you just gotta go out there and do it!" is often terrible advice. It's a recipe for disaster for people with serious disabilities.
I think most people who make, "I used to be X, too," statements are trying to be encouraging. They may, ofc, at the same time be using it for some other reason, since most behaviors are over-determined (have more than one goal). Some use it as a cheap way to inflate their own egos ("I used to be X, but now I'm doing amazing;" ie. "Look how much smarter/wiser/harder-working/determined/etc., I am than you are.") It's people like that I can't stand. You can usually tell who they are because they get mad at you when you reject their advice.
I love Society. It is entirely composed now of beautiful idiots and brilliant lunatics. Just what Society should be.