Preheat the oven to 350°F (175°C). Grease and flour the cake pans.
In a mixing bowl, whisk together flour, sugar, baking powder, baking soda, cinnamon, nutmeg, and salt.
In another bowl, mix the oil, eggs, and vanilla. Gradually add the dry ingredients to the wet ingredients, 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 comes out clean.
Allow cakes to cool in pans for 10 minutes, then transfer to wire racks to cool completely.
For frosting, beat together cream cheese and butter until smooth. Gradually add powdered sugar and vanilla, beating until fluffy.
Once the cakes are cooled, spread frosting between the layers and on top and sides of the cake.
For extra flavor, consider adding raisins or coconut to the batter.
Store any leftovers in an airtight container in the fridge for up to 3 days.