Heat the oven to 350°F (175°C). Grease the pans and line their bottoms with parchment. Finely grate peeled carrots using a box grater.
Whisk flour, baking powder, baking soda, cinnamon, and salt. In another bowl whisk both sugars, oil, eggs, and vanilla until uniform.
Fold dry ingredients into the egg mixture. Stop before overmixing, then fold in grated carrots and optional chopped walnuts.
Divide batter between pans and smooth the tops. Bake 30–38 minutes, until the centers spring back and a tester shows only moist crumbs.
Cool layers in their pans for 15 minutes. Turn onto a rack, remove parchment, and let them cool completely before frosting.
Beat softened butter until smooth, then briefly beat in cream cheese. Add powdered sugar gradually and mix in vanilla until creamy.
If the frosting becomes soft, refrigerate it for 15–20 minutes. Spread some between the cooled layers and cover the outside with the remainder.
Refrigerate the assembled cake for at least 30 minutes before slicing. Use a clean knife and return leftovers to the refrigerator promptly.