When a wizard learns true polymorph, do they also learn about every creature in existence? Since the spell says the new form can be a creature of any kind you choose, it seems to me that this would mean they must have gained some knowledge about every creature in existence.
Or can you only turn into creatures that you have encountered "in your lifetime"?
No, but its up to the DM what this means.
There is no rule that states the learning true polymorph gives any knowledge beyond how to cast the spell. That said, it's going to be up to the DM to determine if your particular choice of creature is permitted in game.
When it comes to (true-)polymorph, I have always ruled that there is a reasonable expectation that the caster has seen or learned about the creature some time in their past. For most creatures my players have ever come up with, this hasn't been an issue. However, I have ruled against using dinosaurs before, even though they are beasts and appear in the Monster Manual, because they didn't even exist in my world. There have been a few other times where I have said, "you know about that because you have read the Monster Manual, your character has most likely never seen that, pick a different creature."
The motivating principle behind ruling this way is that you have to know what your choices are to be able to choose them. This rarely is an issue, and when it has come up, I have never had players get upset over my ruling. Why? I discuss this with my players when they reach a point where they can learn polymorph. I tell my polymorph hopefuls that I intend to rule this way so it is no surprise when the deep-gnome sorcerer that grew up under a mountain is told she cannot become a sperm whale.