Preheat your oven to 350°F (175°C) and line a muffin tin with paper liners.
In a large bowl, whisk together the flour, baking powder, baking soda, salt, cinnamon, and nutmeg.
In another bowl, mix the granulated sugar, brown sugar, and vegetable oil until well combined.
Add the eggs one at a time, mixing well after each addition.
Stir in the grated carrots and crushed pineapple.
Gradually add the dry ingredients to the wet ingredients, mixing until just combined.
If using, fold in the chopped walnuts gently.
Divide the batter evenly among the muffin liners, filling each about two-thirds full.
Bake for 20-25 minutes or until a toothpick inserted into the center comes out clean.
Allow the muffins to cool in the tin for 5 minutes before transferring them to a wire rack.