In a 12-inch frying pan or 5- to 6-quart pan over medium-high heat, melt 2 tablespoons of the butter. Add mushrooms and stir often until almost tender, 4 to 5 minutes. Add garlic and stir until mushrooms are golden and tender to bite, 2 to 3 minutes longer. Transfer to a bowl.
Trim and discard root ends and tough green tops from leeks. Cut stalks in half lengthwise and rinse well under running water, flipping layers to release dirt. Cut crosswise into 1/4-inch slices; you should have about 4 cups.
In the frying pan (no need to wash), over medium-high heat, melt remaining 2 tablespoons butter. Add leeks and thyme and stir often until leeks are limp and beginning to brown, 8 to 10 minutes. Stir into mushrooms.
Preheat oven to 350°. Peel and slice potatoes crosswise as thinly as possible (see notes). In a bowl, whisk together broth, cream, wine, salt, and pepper. In a buttered 9- by 13-inch baking dish (3-qt. capacity), evenly layer a third of the potatoes, half of the mushroom-leek mixture, and 1 cup cheese. Stir broth-cream mixture and pour a third evenly over the top. Repeat. Layer remaining potatoes, cheese, then cream mixture on top. Set dish in a 10- by 15-inch baking pan.
Bake until potatoes are tender when pierced and sauce is bubbly, 1 1/2 to 1 3/4 hours. After about 40 minutes, check browning; if top begins to get dark before potatoes are tender, cover loosely with foil. Let stand about 15 minutes before serving.