Prepare the oven and baking dish. Preheat the oven to 375°F (190°C). Lightly grease an 8 × 8-inch baking dish with cooking spray or a little butter.
Prepare the spinach and artichokes. Thaw the spinach completely and squeeze out as much excess moisture as possible. Drain the artichoke hearts, chop them into bite-sized pieces, and set aside.
Make the creamy mixture. In a large mixing bowl, combine the softened cream cheese, sour cream, mayonnaise, and minced garlic. Stir until smooth and creamy.
Add the vegetables and cheese. Fold in the spinach, chopped artichoke hearts, mozzarella, Parmesan, salt, black pepper, and red pepper flakes, if using. Mix until everything is evenly combined.
Transfer to the baking dish. Spread the spinach and artichoke mixture evenly into the prepared baking dish. Sprinkle a little extra mozzarella or Parmesan over the top if desired.
Bake the casserole. Place the dish in the preheated oven and bake for 25 to 30 minutes, or until the casserole is bubbling around the edges and the top is lightly golden.
Rest and serve. Let the casserole rest for about 5 minutes before serving. This helps the creamy filling settle slightly and makes it easier to scoop.