Preheat the oven to 350°F (175°C). Grease and flour two 9-inch round cake pans.
In a medium bowl, whisk together the flour, baking powder, baking soda, salt, cinnamon, and nutmeg. Set aside.
In a large mixing bowl, combine the granulated sugar, brown sugar, and vegetable oil. Mix until well combined.
Add the eggs one at a time, mixing well after each addition. Stir in the vanilla extract.
Gradually add the dry ingredients to the wet mixture, mixing until just combined.
Fold in the grated carrots, crushed pineapple, and walnuts (if using).
Divide the batter evenly between the prepared cake pans.
Bake for 25-30 minutes, or until a toothpick inserted into the center comes out clean.
Allow the cakes to cool in the pans for 10 minutes, then transfer to wire racks to cool completely.
For the frosting, beat the softened cream cheese and butter together until smooth. Gradually add the powdered sugar and vanilla extract, mixing until well combined. Add milk as needed to reach desired consistency.
Once the cakes are completely cool, spread a layer of frosting on top of one cake layer, place the second layer on top, and frost the top and sides of the cake.