Preheat the oven to 350°F (180°C).
Heat the olive oil in a large skillet over medium-high heat. Add the finely chopped onion and carrot and cook, stirring occasionally, for 3–4 minutes until softened and translucent.
Add the minced garlic and cook for about 30 seconds until fragrant, then stir in the passata (or marinara) and all seasonings: dried Italian herb, oregano, sugar, ground fennel, garlic powder, onion powder, 1 teaspoon salt, and black pepper.
Reduce heat and let the sauce simmer gently while you cook the pasta.
Bring a large pot of salted water to a boil. Add 1 tablespoon salt and the ziti and cook until 2 minutes less than the package directions indicate. Reserve 1/3 cup of the pasta cooking water, then drain the pasta and return it to the pot.
Add 2 cups of the prepared sauce and the reserved 1/3 cup pasta water to the drained pasta and toss gently to combine.
Spread the sauced pasta evenly in a 9×13-inch (23x33 cm) baking dish. Dollop spoonfuls of ricotta over the pasta, then pour the remaining sauce on top. Sprinkle the shredded mozzarella and parmesan evenly over the dish.
Bake in the preheated oven for 25 minutes, until the cheese is golden and bubbling.
Remove from the oven and sprinkle with chopped parsley or basil if using, then serve.