Preheat oven to 375 degrees F (190 degrees C). Grease a 9x13-inch baking dish.
Heat vegetable oil in a large saucepan over medium-high heat. Cook and stir yellow summer squash, zucchini, and red onion in hot oil until softened, about 10 minutes; season with garlic powder and black pepper. Stir Parmesan cheese into the squash mixture. Turn off the heat and add margarine and cream cheese, breaking them into smaller pieces as you stir them into the squash mixture; remove the saucepan from heat. Stir kernel corn and 1 can cream-style corn through the squash mixture.
Stir remaining can of cream-style corn, dry corn muffin mix, eggs, and sugar in a large bowl until thoroughly mixed. Add the cooled squash mixture, 1 to 2 cups at a time, until completely integrated; pour into prepared baking dish.
Bake in preheated oven until browned and bubbling on the edges and firm on top, 30 to 50 minutes. Allow to cool at least 5 minutes before serving.