Heat 1 tablespoon olive oil in a saucepan over medium heat. Add garlic and red pepper flakes; cook and stir until golden, about 1 minute. Stir in basil and oregano; cook until fragrant, about 1 minute. Stir in tomato sauce. Simmer sauce until flavors combine, about 20 minutes.
Combine spinach and 2 tablespoons water in a large skillet over medium heat. Cover and cook until spinach is wilted, 3 to 5 minutes. Drain and cool until easily handled, about 5 minutes. Gather spinach into a ball and squeeze out excess water. Chop coarsely.
Combine chopped spinach, ricotta, and ½ cup Parmesan cheese in a bowl.
Preheat oven to 400 degrees F (200 degrees C). Line 2 baking sheets with parchment paper.
Divide eggplant, red bell pepper, and orange bell pepper between lined baking sheets. Drizzle with 2 tablespoons olive oil and toss to coat. Season with salt and pepper.
Roast in the preheated oven, stirring every 10 minutes, until tender and browned in spots, about 30 minutes. Remove from oven.
Bring 6 cups water to a boil; add salt. Pour in polenta in a steady stream, whisking constantly. Reduce heat to low. Whisk until polenta thickens, about 5 minutes. Cover and cook, stirring vigorously every 10 minutes, until polenta is the consistency of porridge, about 30 minutes.
Reduce oven temperature to 350 degrees F (175 degrees C). Grease a 9x13-inch baking dish with cooking spray.
Spread half the polenta evenly in the bottom of the baking dish. Layer half of the spinach mixture, roasted vegetables, and sauce on top. Top with ½ cup mozzarella cheese and ¼ cup Parmesan cheese. Repeat layers with remaining polenta, spinach mixture, roasted vegetables, and sauce. Top with remaining mozzarella cheese and Parmesan cheese.
Bake in the preheated oven until cheese melts and sauce is bubbly, about 20 minutes. Let cool before cutting so layers hold, at least 20 minutes.
Filling, tomato sauce, and vegetables can be made ahead and refrigerated. Bring to room temperature before assembling. The polenta needs to be cooked just before assembly because it firms up when it cools and cannot be poured or spread.