Heat the oven to 350°F (175°C). Grease two 9-inch round cake pans, line the bottoms with parchment, and grease the parchment.
Whisk the flour, baking soda, baking powder, cinnamon, nutmeg, and salt together in a medium bowl.
In a large bowl, whisk the granulated sugar, brown sugar, eggs, oil, and vanilla until smooth and slightly thick.
Add the dry ingredients to the wet mixture and stir just until no flour streaks remain.
Fold in the grated carrots, walnuts, and raisins if using.
Divide the batter evenly between the pans and smooth the tops.
Bake for 35 to 40 minutes, until a toothpick pushed into the center comes out clean.
Cool the cakes in the pans for 10 minutes, then turn them out onto a rack and cool completely.
For the frosting, beat the cream cheese and butter together until smooth, then beat in the powdered sugar a cup at a time, followed by the vanilla and salt.
Spread frosting over the first layer, set the second layer on top, and frost the top and sides. Scatter extra chopped walnuts over the top before serving.