Latin didn't go extinct at all. It just changed. All languages do.
While the Roman Empire existed as a political entity, Latin tended to evolve in the same direction all over the empire. Children in Gaul were taught the same Latin as children in Spain. That changed when the Empire fell. Without a central authority to keep the language uniform, speech began to separate in the parts of the former empire. Over hundreds of years, those regional variations became dialects of Latin, then gradually different enough that they were separate languages. This happens all the time. In most places, the old form of the language isn't considered "dead", just changed. We don't think of Old English or Middle English dead languages. We actively speak the thing they turned into.
The Romance languages are the same thing, but are essentially different versions of modern Latin. But something odd happened with Latin. It's use was preserved in Western Europe as a language of the Church, law, diplomacy, and scholarship, in a way that few other languages have been preserved. Very few languages continue to be even thought of, much less actively used, once they no longer have native speakers. The only reason we think of Latin as a dead language is that we continue to use it at all.
Well, in a sense, it isn't: countless people still speak its direct descendants, the Romance languages: Italian, Spanish, French etc.
It's like asking how did Old English going from being the language of the British Isles to something only scholars can understand: languages evolve and change constantly. And eventually the works written in the older forms become incomprehensible to modern speakers without extensive study.