Preheat oven to 375°F (190°C). Lightly grease a 9x9‑inch baking dish with a little butter or nonstick spray.
Peel the potatoes and slice them about 1/8 inch thick, using a mandoline or sharp knife. Place the slices in a bowl of cold water to prevent browning and remove excess starch.
Drain the potatoes and pat them dry. Toss them with 2 tablespoons butter and a pinch of salt. Add the sliced onion and mix gently.
Spread half of the potato‑onion mixture into the prepared baking dish.
In a medium saucepan, melt 2 tablespoons butter over medium heat. Stir in the flour and whisk for about 1 minute until slightly golden.
Add the garlic powder, onion powder, smoked paprika (if using), salt, pepper, and thyme. Stir for 30 seconds so the flavors bloom.
Gradually pour in the warm milk while whisking continuously. Add the heavy cream and keep whisking until the sauce thickens enough to coat the back of a spoon, about 5–7 minutes.
Remove the saucepan from the heat. Stir in 1 cup of cheddar cheese and the Parmesan until smooth and melted. Add a pinch of cayenne if desired. Taste and adjust seasoning.
Spread the remaining potatoes and onions over the dish, pressing them down gently. Pour the cheese sauce evenly over the top, making sure it reaches into the gaps.
Sprinkle the remaining 0.5 cup cheddar cheese over the surface. Cover the dish tightly with aluminum foil.
Bake for about 45 minutes, then remove the foil and bake 20–25 minutes more, until the top is golden brown, the cheese is bubbly, and the potatoes are tender when pierced with a knife.
If you like a crispier top, broil for 2–3 minutes, watching closely so it doesn’t burn. Let the Cheesy Scalloped Potatoes rest 10–15 minutes before serving so the sauce sets slightly.