Preheat the oven to 425°F.
Make the sauce. Heat a large pot over medium heat. Add the oil and onion and cook until soft. Add the garlic and anchovies (if using) and cook until fragrant, 1-2 minutes. Stir in the tomato paste and cook 1-2 minutes. Add the tomatoes, thyme, salt, and pepper. Simmer uncovered 15-20 minutes to reduce slightly, then season to taste.
Boil the water. Bring a large pot of salted water to a boil for the pasta.
Prep the cheeses. Shred the mozzarella and Parmesan. Set aside 1½ cups mozzarella and ⅓ cup Parmesan for the topping. In a bowl, combine the remaining mozzarella and Parmesan with the ricotta, heavy cream, salt, and pepper.
Cook the pasta for about 8 minutes, until slightly firmer than al dente. Drain and toss with a little olive oil to prevent sticking.
Divide. Split the cheese mixture and the beef into four equal portions, one per layer.
Assemble. Spread 1 ladle of sauce on the bottom of the dish. Build 5 layers of pasta and 4 layers of filling. Each filling layer gets one portion of the cheese mixture, one portion of the beef, and 2 ladles of sauce. Finish with the last pasta layer, the remaining sauce, and the reserved mozzarella and Parmesan.
Bake until the top is deeply browned and bubbly, about 45 minutes, uncovered.
Rest at least 20 minutes before cutting and serving.