Fill a large pot with water and bring to a boil over high heat.
Add a small handful of salt and macaroni and stir together.
Boil macaroni until al dente, 8 to 10 minutes, stirring occasionally.
Remove macaroni from heat and reserve 1 cup of the pasta water.
Drain pasta and rinse with cold water to stop cooking.
Place pot back over medium heat and melt butter. Add shallot and garlic and sauté for 3 to 4 minutes. Season with salt and pepper.
Add corn and continue to sauté for 3 to 4 minutes. Sprinkle sugar over corn mixture and continue to sauté for an additional minute.
Remove ⅔ cup corn mixture from pot and set aside.
Sprinkle flour over corn mixture remaining in pot and stir together until there are no raw lumps of flour left, 3 to 4 minutes.
Slowly stir milk into the flour mixture and continue to stir together until mixture is smooth and begins to simmer and thicken enough to coat the back of a spoon.
Remove pot from heat and stir in the shredded swiss followed by the cheddar, slowly and in small handfuls, until all the cheese has been added and melted into a smooth sauce. Season with salt and pepper.
Fold in the cooked macaroni until fully incorporated and any of the reserved pasta water as needed if the mixture is too thick, 2 tablespoons at a time, until the macaroni and cheese is creamy and smooth.
Adjust seasonings, stir and top with reserve corn mixture. Serve.