Gymnasts can have their body type for both reasons that you’ve said: because that’s what they’re like naturally and also because the training shapes them into that body size.
By the way, it is pretty long what I’ve written, so feel free to skip to the end for my conclusion
I’ll talk about Artistic gymnasts (which is more my forte), and compare them to Rhythmic gymnasts.

Basketball doesn't make basket ball players tall does it? They're chosen because that’s more desired.
A lot of young gymnasts will get handpicked for the sport because of their body.
The image of an Artistic gymnast is a short, skinny young girl, like Shawn Johnson (pictured). But that doesn’t mean that all short skinny young girls will be perfect for Artistic gymnasts.
They might not have the desire or balance or co-ordination needed.
Even though the image of an Artistic gymnast is supposed to be short, this hasn’t stopped taller gymnasts from having success, like Svetlana Khorkina.
In Rhythmic Gymnastics, the image of the gymnasts is that they are taller, skinnier, and a lot more flexible. Gymnasts like Anna Bessonova or Evgeniya Kanaeva.
Of course through the training they increase their flexibility and strength over years of practise.
But, RG legend Alina Kabeava was a shorter, curvier gymnast who impressed her coach Irina Viner enough to let her train with her because of her agility and flexibility. So having the perfect Rhythmic body isn’t always necessary.
Now the difference between the two types of gymnasts.
Even though Artistic and Rhythmic gymnasts train the same amount of hours, their training is very different because of what their sports demand of them, so the body types will evolve differently.
Artistic gymnastics involves tumbling and vaulting, so they need more explosive muscles for this.
They don’t really focus on dance much since it won’t reward them as much difficulty, and only need to hit 180’ degrees on their splits.
And because the gymnasts can be training long hours since they're young, and won't have alot of body fat because of the amount of exercise, and also from a very healthy diet, puberty will be delayed until their bodies have the required amount of fat.
That is until they quit or get injured and can't train, so since they're not burning their fat through exercise, they now have enough fat for their bodies to go through puberty. So their bodies change: they grow taller, they develop breasts etc., and it can be really difficult to adjust to this new body.
Especially on beam, because your centre of gravity has changed, and you’ll have to get more strength to handle this increased weight gain.
Some gymnasts will quit because of this, so you won’t see the taller gymnasts compete, only the younger short ones.
But not all gymnasts will grow taller. Shawn Johnson (who I mentioned before) hasn’t done gymnastics in over a year, but is still very short, so naturally she must just be this way.
Whereas Rhythmic is more about dance skills and flexibility, so they focus on the flexibility and ballet training alot more than in WAG.
And since their body lines are important, they focus on lengthening those lines with alot of flexibility training, making their muscles longer, and diet more so they won't be as "fat" so they can show it off.
Irina Tchachina wasn’t naturally a flexible gymnast, but worked hard on improving this, so possibly her body could be different to what it’s naturally supposed to be like.
To conclude:
So some gymnasts may be chosen because of their body types, giving them an advantage, and through years of practise becomes a good rhythmic gymnast.
But some may have to work against their body type, and through a lot of hard work become a good rhythmic gymnast.
THE END
Sorry, in places I kind of rambled off, and I’m not the most knowledgeable person on this, but I hope this helps!