I just heard “the lyrics to the song” and I thought te correct way to say it is “the lyrics of the song”. Am I right? Otherwise, what’s the difference? I’ve gotten this doubt because I’ve heard “to” instead of “of” expressing belonging in another sentences and I couldn’t understand why that is correct.
Both would be understood, but I tend to agree with you that it should be "the lyrics of the song". The lyrics are considered a part of the song, and as such are spoken of in the possessive, eg "the song's lyrics".
I suspect that the use of "to" comes from the fact that lyrics are words set to music. Historically, a lot of songs began as melodies only, and then words were put to them. As such "the words to the song" sounds quite idiomatic to my ears, but "lyrics of the song.