Preheat the oven to 350 degrees. In a large skillet, heat 2 tablespoons butter over medium-high heat. Add the onion and cook until softened, 3 to 5 minutes. Add the beef and cook until no longer pink, about 5 minutes. Stir in the cinnamon and nutmeg and season with salt and pepper. Add the tomato sauce and cook until most of the liquid has evaporated, 3 to 5 minutes. Pour into an 8-inch square baking dish and set aside.
In a medium bowl, lightly beat the eggs and set aside. In a small saucepan, melt the remaining 2 tablespoons butter over medium-high heat. Whisk in the flour and cook, whisking often, until the mixture is smooth, about 30 seconds. Slowly whisk in the milk until thickened. Lower the heat to medium and stir in the cream cheese and ricotta; season with salt and pepper. Whisk one-quarter of the cheese sauce into the reserved eggs until smooth. Whisk the egg mixture into the cheese sauce in the saucepan.
Pour the sauce over the meat in the baking dish and spread evenly. Bake until the top is lightly browned and firm to the touch, 40 to 45 minutes. Let cool for 10 minutes; cut into squares to serve.