Preheat oven to 425°F. Toss together tomatoes, onion, carrots, garlic, salt, pepper, and 3 tablespoons oil on a large rimmed baking sheet; spread in an even layer.
Roast in preheated oven until tomatoes are broken down, garlic is very soft, and carrots are fork-tender, about 35 minutes.
Process tomato mixture, anchovies (if using), basil, sugar, and remaining 4 tablespoons oil in a blender until smooth, about 30 seconds, stopping to scrape down sides of container. Season to taste with additional salt and pepper (see Note). Use immediately. Note: If you plan to use this sauce with pasta cooking water, wait until your desired consistency is reached with the added pasta cooking water before adjusting seasoning to taste.
