Preheat your oven to 400°F and grease a 9-by-13-inch (or another 3-quart) baking dish with butter. In a large pot, bring salted water to a boil, add the spaghetti, and cook it according to the package instructions. Once done, drain the pasta and set it aside.
Next, melt the butter in the same pot over medium-high heat. Add the beef, 1 teaspoon of salt, garlic powder, onion powder, and red pepper flakes. Break up the meat with a wooden spoon and cook until it is browned and fully cooked, about 7 minutes.
Stir in the marinara sauce, bring the mixture to a simmer, and let it cook for about 3 minutes. Then, remove the pot from the heat and mix in the cooked spaghetti and ricotta cheese. Transfer the mixture to the prepared baking dish, scatter the mozzarella and parmesan on top, and bake for about 30 minutes until the cheese is bubbling and browned.