Preheat oven to 350°F / 177°C. Spray a 2-quart casserole dish (or use a 9-inch pie plate or 9-inch cake pan) with nonstick cooking spray or brush with some oil.
In a large saute pan over medium heat, melt 4 Tablespoons butter. Add onion and garlic and saute until onion is very soft, 7 to 8 minutes.
To onion mixture, add salt, black pepper, nutmeg, and baby spinach. Saute until spinach is wilted (put the lid on to speed it along) and all of the liquid has cooked off, 7 to 8 minutes.
Remove spinach from heat and whisk in heavy cream, parmesan cheese, and nutmeg.
Layer squash and spinach-cream mixture, using about one fifth of squash and one fourth of spinach for each layer, beginning and ending with squash.
Scatter parmesan cheese over top of casserole and dot with pieces of the remaining 2 Tablespoons of butter.
If using a baking dish with shallow sides (like a pie plate) place it on a sheet pan to catch any liquid that bubbles over).
Cover baking dish tightly with foil and bake until squash is nearly tender, 30 minutes.
Remove foil and continue baking until casserole is golden brown on top and bubbling around the sides, about 15 minutes more.