Heat the oven to 350°F/180°C.
In a large skillet over medium heat, melt the butter with the olive oil. Add the shallots and cook, stirring occasionally, until soft and translucent, 3 to 4 minutes. Add the leek and cook until tender and lightly softened, about 5 minutes. Add the thyme and cream, season with the salt and pepper, and bring to a gentle simmer. Cook until slightly thickened and the flavors meld, 8 to 10 minutes. Remove from heat, discard the thyme sprig, and stir in the Parmesan.
Arrange a tight, slightly overlapping layer of potato slices in a buttered baking dish. Spoon over half of the cream mixture and spread evenly. Sprinkle half of the mozzarella. Add a second layer of potatoes, then pour over the remaining cream mixture and smooth the top. Finish with the remaining mozzarella and the Gouda.
Cover tightly with foil and bake until the potatoes are tender when pierced with a knife, about 45 minutes. Remove the foil and continue baking until the top is deeply golden brown and bubbling, 20 to 25 minutes more. Let rest for 10 minutes before serving.