CW, welcome back to the Grammar Exchange.
Correct me if I'm wrong, but it seems that you understand how it's being used, at least, in the phrase "[t]he song ... has a line ...". But perhaps you're quoting. I don't know where you're from or how well you know English, so I'll back up a little.
I think that, growing up, my original concept of a "line" was something that was drawn on paper and looked like this:
Of course, this concept could be extended to other things, like a line of dots:
or a line of words:
Shall I compare thee to a summer's day?
(This is taken from a sonnet by William Shakespeare.)
When speaking of stories and essays, we expect the words to be grouped in paragraphs. In poetry, we separate them into lines. This arrangement usually reflects the authors sense of how the rhythm should be. A sonnet, for example, always has fourteen lines. Each "line" is generally short enough that it can occupy a single row of typeset, hence my "line of words" example above.
Song lyrics are a form of poetry, so we speak of "lines of songs" in the same way that we speak of "lines of poetry". Thus, each of the songs you mention consists of lines, and each song contains at least one line that makes mention of somebody else's lines. So, what about these other lines?
Historically, stage plays were written in verse form, as if they were poetry. We could speak, for example, of "line 53 of scene 2 of act 3 of Shakespeare's Julius Caesar
". Even though most plays are no longer written in verse, we still refer to the dialog as "lines", and, in fact, this terminology has carried into the motion picture industry as well.
Let's start with (2), which I believe you mean to refer to "Send in the Clowns
" by Stephen Sondheim from his musical play A Little Night Music
. In the play, the character who sings the song is herself a stage actress. She sings of
Making my entrance again with my usual flair
Sure of my lines
These are standard requirements of any great stage actress. In the context of the play, however, she also seems to be applying her stage training to her personal life. She has found the man she wants, and is determined to make an impression on him by "making an entrance ... sure of [her] lines". She has already practiced and rehearsed what she wants to say to him.
In your other example, the situation is different only in that the man is not a professional actor, although the use of the term "lines" derives from the theatrical use. There are certain things he has learned how to say that he knows will make her forgive him. He has probably even practiced exactly how to say them.
Yes, "line" has a great many meanings. I don't have time to go into them all today, but I hope this helps for now.