Here's how this works.
(Note: I am using the terms c-level and s-level to clearly differentiate between character levels and spell levels, as this is sometimes confusing).
When a Sorcerer's "Spells Known" count goes higher, they learn 1 new spell of any s-level they are able to use. Additionally, any time they level up, they can trade out one spell they already know, for a new spell of any s-level they are able to use. In essence 'forgetting' how to cast that spell in favor of learning a new one. So, to give an example...
A c-level 1 Sorcerer knows 2 spells of first s-level.
A c-level 2 Sorcerer knows a total of 3 spells of first s-level, and can swap out one spell they knew at c-level one for a different spell if they want to.
A c-level 3 Sorcerer knows a total of 4 spells split between First and Second s-level. By the rule of how this works...they can pick a 4th first s-level spell OR a single 2nd s-level spell. Additionally, if they want to, they can trade out one of the spells they knew at 2nd c-level for a new spell of First or Second s-level.
A c-level 4 Sorcerer knows a total of 5 spells, worked out the same way. Add one new spell of First or Second s-level...trade one spell you knew at c-level 3 for a new spell of First or Second s-level if you want to.
Continue to repeat for the rest of leveling. Every time you level up, you can trade one spell you knew for a new spell of any s-level you can cast. Every time your Spells Known increases, add one new spell for any s-level you are able to cast.
So, to clearly answer your question...a 5th level Sorcerer could have anywhere from 6 First s-level Spells to 4 2nd s-level spells and 2 3rd s-level spells (assuming they 'traded out' every first s-level spell they were able to when they leveled up) or any combination in between.
Reminder: There's a reason I used the term "You are able to use" instead of "that you have spell slots for." If you are multi-classing, you may only learn spells of a level that you could use if you were a single classed member of that class. I.e. a 17th level Wizard can't take a 1 level dip into Cleric and Druid and thus have access to virtually every spell in the game. They could cast up to 9th level Wizard spells, but only 1st level Cleric and Druid spells. Yes, this means that while a Wizard 4/Cleric 1 may have 3rd level spell slots, they are not be able to learn or prepare any 3rd level spells.