The recommended balance between 5 servings of vegetables and 2 servings of fruit is only one of different recommendations, for example, Dietary Guidelines for Americans by U.S. Department of Health and Human Services and U.S. Department of Agriculture recommend 2.5 cups of vegetables and 1 cup of fruits per day in a 2,000 Calorie diet. On that same page, you can see they've put tomatoes into a vegetable group.
From the nutrition viewpoint, the main difference between vegetables and fruits is in their sugar content. A 100 g tomato contains only ~2.6 g of sugars, while an apple contains ~10 g. There seems to be no exact sugar amount determined that would put a certain plant into a fruit category, though.
There is no essential nutrient that vegetables, as a group, would have and fruits wouldn't. A certain vegetable and a certain fruit can contain more similar amounts of a certain nutrient, for example, potassium than 2 fruits or 2 vegetables (PubMed, Table 3).
All this suggests that one doesn't need to be too worried about what counts as a vegetable or a fruit and how many servings of each to eat but think which foods to eat to get all the essential nutrients.