Preheat the oven to 350°F (175°C).
In a large pot, bring salted water to a boil and add the elbow macaroni. Cook according to package instructions until al dente, then drain and set aside.
In a skillet over medium heat, add the ground beef and cook until browned, breaking it apart with a wooden spoon. Drain any excess fat.
Add the chopped onion and minced garlic to the skillet. Cook for about 3-4 minutes until the onion is translucent.
Stir in the tomato sauce, diced tomatoes, oregano, basil, salt, and pepper. Let it simmer for 5 minutes.
Combine the cooked macaroni with the beef mixture, stirring well to combine.
Transfer half of the pasta and beef mixture to the baking dish. Sprinkle half of the cheddar and mozzarella on top. Repeat with the remaining pasta mixture and cheeses.
Cover the baking dish with aluminum foil and bake in preheated oven for 20 minutes.
Remove the foil and bake for an additional 10 minutes or until the cheese is bubbly and golden.
Remove from the oven and let it cool for a few minutes before serving.