Cook the pasta: Boil spaghetti in a large pot of salted water until al dente according to package directions. Reserve 1/2 cup of pasta water before draining in case you need to thin the sauce later.
Prepare the sauce base: In a large skillet over medium heat, melt the butter and add minced garlic. Sauté for 1-2 minutes until the garlic becomes fragrant but not browned.
Cook the ham: Add the diced ham to the skillet and cook for 3-4 minutes, allowing it to get slightly crispy around the edges and release its flavor into the butter.
Create the creamy sauce: Reduce heat to medium-low and pour in the heavy cream and milk. Add both Parmesan and mozzarella cheeses, stirring continuously until completely melted and the sauce begins to thicken. Season with salt and pepper to taste.
Combine pasta and sauce: Add the drained pasta directly to the sauce in the skillet. Toss thoroughly until every strand is evenly coated with the creamy sauce. If the sauce seems too thick, add a splash of the reserved pasta water to reach your desired consistency.
Finish and serve: Transfer to a serving dish, garnish with chopped fresh parsley or cilantro if desired, and serve immediately while hot.