Most people have some pretty deep grooves in their back teeth which will develop cavities at some point. For most people they may need them to be filled anytime in their late 20’s-40’s. It’s probably one of the most subjective decision dentists make when to fill those. They don’t show up on X-rays well and sometimes can look a lot deeper than they actually are. Some dentists fill those at the earliest sign and some watch them for a long because they are slow to develop due to the amount of enamel on the biting surface of our teeth. The benefit to filling them early is they should pretty much last you most of the rest of your life. They rarely need to be replaced especially if small.
So that’s awesome your dentist took care of those for you when he did. Sounds like you haven’t had any problems since which is great.