There are two leaderboards in the game: Best Score Leaderboard and Total Score Leaderboard. The Best Score Leaderboard shows your level score for a definite level while the Total Score Leaderboard shows your score for all the levels in total.
Your highest score for a level is always recorded and saved as your best score to the Best Score Leaderboard.
The Total Score is the sum of the highest scores for all the levels you've completed. So, not all the scores are totaled, but only the highest scores. If your friend leaves you behind on the Best Score Leaderboard, you still can have a better Total Score than your friend.
When you complete the match-3 level you may check the Best Score Leaderboard and the Total Score Leaderboard. Switch tabs to choose the one.