Imagine you're practicing for an exam. Each question comes with the correct answer.
Question: 5 + 7 = ?
Answer: 12
You solve thousands of questions like this. Eventually, you learn the pattern.
Machine learning works exactly the same way. The computer learns from examples that already contain the correct answer. This is called supervised learning.