Preheat the oven to 350°F (175°C) and line a muffin tin with paper liners or grease with cooking spray.
In a large bowl, whisk together the flour, baking powder, baking soda, cinnamon, nutmeg, and salt.
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 and raisins.
In a separate bowl, beat together the softened cream cheese, granulated sugar, egg, and vanilla extract until smooth.
Spoon the carrot muffin batter into the prepared muffin tin, filling each cup about two-thirds full. Drop a spoonful of the cream cheese mixture on top of each muffin and use a toothpick or knife to swirl it gently into the batter.
Bake for 20-25 minutes or until a toothpick inserted into the center comes out clean. Let the muffins cool in the pan for 5 minutes before transferring them to a wire rack to cool completely.