A peach is a fruit, whoever you are, and a carrot is definitely a vegetable. But in the Venn diagram relating these two produce categories, there's a sizeable region of overlap. It results from the fact that "fruit" and "vegetable" are defined differently depending on whether you're a gardener or a chef.
Dead center of the overlapping region sits the tomato. So, why is it a fruit, and why is it a vegetable?
Botanically speaking, a fruit is a seed-bearing structure that develops from the ovary of a flowering plant, whereas vegetables are all other plant parts, such as roots, leaves and stems. By those standards, seedy outgrowths such as apples, squash and, yes, tomatoes are all fruits, while roots such as beets, potatoes and turnips, leaves such as spinach, kale and lettuce, and stems such as celery and broccoli are all vegetables.
The outlook is quite different in culinary terms, however. A lot of foods that are (botanically speaking) fruits, but which are savory rather than sweet, are typically considered vegetables by chefs. This includes such botanical fruits as eggplants, bell peppers and tomatoes.
The fruit vs. vegetable debate can sometimes reach such a fever pitch that the law must step in. In the 1893 United States Supreme Court case Nix. v. Hedden, the court rule unanimously that an imported tomato should be taxed as a vegetable, rather than as a (less taxed) fruit. The court acknowledged that a tomato is a botanical fruit, but went with what they called the "ordinary" definitions of fruit and vegetable — the ones used in the kitchen.