Preheat the oven to 375°F (190°C). Lightly grease a 9 × 13-inch baking dish with butter. This helps prevent the potatoes and cheese sauce from sticking to the bottom and sides during baking.
Peel the potatoes if desired, then cut them into even slices about ⅛ inch thick. A mandoline can help create uniform slices, but a sharp knife works well too. Keep the slices similar in thickness so they cook evenly. If rinsing the potatoes, drain and pat them dry before assembling.
Melt 2 tablespoons of butter in a medium saucepan over medium heat. Add the minced garlic and cook for about 30 seconds, stirring constantly until fragrant. Avoid browning the garlic, as it can develop a bitter taste.
Sprinkle the flour over the melted butter and garlic. Whisk for about 1 minute to form a smooth paste. Gradually pour in the milk and heavy cream, whisking continuously to prevent lumps. Add the salt, black pepper, onion powder, and optional nutmeg. Cook for 3–5 minutes, stirring frequently, until the sauce thickens slightly.
Remove the saucepan from the heat and stir in 1½ cups of shredded cheddar cheese until melted into the sauce. Reserve the remaining ½ cup for the topping. The sauce should be smooth and creamy, with enough consistency to coat the back of a spoon.
Arrange half of the sliced potatoes in the prepared baking dish, overlapping them slightly. Pour half of the cheese sauce over the potatoes, spreading it evenly. Add the remaining potato slices and cover with the rest of the sauce. Gently press down so the sauce reaches between the layers.
Cover the baking dish tightly with aluminum foil and bake for 45 minutes. Remove the foil, sprinkle the reserved cheddar cheese over the top, and bake uncovered for another 15–30 minutes. The potatoes should be fork-tender, and the top should be golden and bubbling. If the potatoes are still firm, continue baking and check every 5–10 minutes.
Remove the dish from the oven and let it rest for 10–15 minutes before serving. This allows the sauce to settle and thicken slightly, making the potatoes easier to portion. Sprinkle with fresh thyme if desired and serve warm.