Jesus was an itinerant preacher. He taught the same thing multiple times. So, he taught the Lord's Prayer to both the multitudes and to his disciples.
Some argue that the Bible is contradictory concerning who Jesus taught the Lord's Prayer to. Matthew says that Jesus taught the Lord's Prayer to "the multitudes," and Luke 11:1-4
Matthew 5:1, 6
:9-13 ... 5 And seeing the multitudes, He went up on a mountain, and when He was seated His disciples came to Him.
...
9 In this manner, therefore, pray:
Our Father in heaven,
Hallowed be Your name.
10 Your kingdom come.
Your will be done
On earth as it is in heaven.
11 Give us this day our daily bread.
12 And forgive us our debts,
As we forgive our debtors.
13 And do not lead us into temptation,
But deliver us from the evil one.
[a]For Yours is the kingdom and the power and the glory forever. Amen.
1 Now it came to pass, as He was praying in a certain place, when He ceased, that one of His disciples said to Him, “Lord, teach us to pray, as John also taught his disciples.”
2 So He said to them, “When you pray, say:
Our Father in heaven,
Hallowed be Your name.
Your kingdom come.
Your will be done
On earth as it is in heaven.
3 Give us day by day our daily bread.
4 And forgive us our sins,
For we also forgive everyone who is indebted to us.
And do not lead us into temptation,
But deliver us from the evil one.”
The answer is simple. Jesus was an itinerant preacher. He taught the same thing multiple times. So, the answer is that he taught the Lord's Prayer to both the multitudes at the Sermon the Mount and to his disciples.
Some people have trouble accepting possible explanations to alleged contradictions in the Bible, especially ones that they consider a stretch. For example, Dan Barker, president of the Freedom From Religion Foundation, says this:
I have received numerous replies from Christians who think that these contradictions are either trivial or easily explained. Yet not a single "explanation" has been convincing.
The fact is that there are plausible explanations for every alleged contradiction in the Bible. That there is a plausible explanation for an alleged contradiction does not mean that it is definitely the correct explanation for the alleged contradiction.
However, as long as a possible explanation has been suggested, then it has been objectively demonstrated that there is no necessary contradiction regarding the Bible verses and passages brought up.
When people like Dan Barker say that they don't find a particular explanation for a contradiction "convincing," then that is merely their opinion. A plausible explanation has been suggested that eliminates the necessary alleged contradiction. They simply don't like it, which is not at all a relevant argument against the explanation.
To read more about solutions to Bible contradictions and difficulties, check out Norman Geisler's The Big Book of Bible Difficulties: Clear and Concise Answers from Genesis to Revelation. While we do not agree with some of Geisler's theology, particularly concerning his view of predestination, this book is still an excellent resource. It is thorough and filled with research.
Another book to check out is Tim Chaffey's Demolishing Supposed Bible Contradictions: Exploring Forty Alleged Contraditions, which also answers many alleged contradictions in the Bible.