Preheat oven to 375°F. Spray a 9×13-inch baking dish with nonstick spray.
Slice potatoes about ⅛-inch thick. Set aside.
Melt butter in a large saucepan over medium heat. Add onion and cook 3 to 4 minutes. Add garlic and cook 30 seconds.
Sprinkle flour over the onion mixture and stir constantly for 1 minute.
Slowly whisk in milk, then broth. Add salt, pepper, paprika (if using), and thyme. Simmer 4 to 6 minutes, stirring often, until thickened.
Reduce heat to low. Stir in sour cream until smooth. Stir in 2 cups cheddar and ½ cup Monterey Jack until melted. Remove from heat.
Spread a thin layer of sauce in the baking dish. Layer half the potatoes, half the ham, then about a third of the sauce. Repeat with remaining potatoes and ham, then pour remaining sauce over the top.
Sprinkle remaining cheddar and remaining Monterey Jack over the top.
If using topping, mix panko with melted butter and Parmesan, then sprinkle evenly over the cheese layer.
Cover tightly with foil and bake 50 minutes. Remove foil and bake 20 to 25 minutes more, until golden and potatoes are fork-tender.
Rest 10 to 15 minutes before serving. Garnish with parsley if desired.