Bring a large pot of salted water to a boil. Add the spaghetti and cook according to package instructions until al dente, usually around 8-10 minutes. Reserve 1 cup of pasta water, then drain the spaghetti in a colander.
In a saucepan, melt the butter over medium heat. Add the minced garlic and sauté for about 1 minute until fragrant.
Reduce the heat to low, then pour in the heavy cream, stirring constantly. Allow it to simmer gently for 2-3 minutes, then gradually stir in the mozzarella and Parmesan cheese until melted and smooth.
Season the cheese sauce with salt, black pepper, and red pepper flakes (if using). If the sauce is too thick, add some reserved pasta water, a little at a time, until you reach your desired consistency.
Add the drained spaghetti to the cheese sauce and toss until the pasta is evenly coated.
Serve the cheesy spaghetti in bowls, garnished with fresh parsley if desired.