You can’t stop the waves, but you can learn to surf.
― Jon Kabat-Zinn, Wherever You Go, There You Are
Meditation is practice, which helps us develop mindfulness.
Each time you become aware that your mind has wandered to a thought and return to your breath, you have successfully exercised awareness. You have a made free-throw. You have completed a rep. You have sunk a putt. You have practiced successfully, learned, and improved.
If you sat your entire session with a completely empty mind and perfect focus on your breath, there would be little practicing going on, and it would be very difficult to extend mindfulness to the rest of your day.
So when you finish a session during which you noticed many thoughts, don’t despair that you failed; celebrate all the practice you accomplished.