01 - Preheat oven to 375°F. Lightly grease a 9x13-inch baking dish with butter.
02 - Place the peeled and cubed potatoes in a large pot of salted water. Bring to a boil, then reduce heat and simmer until fork-tender, about 15 to 18 minutes. Drain thoroughly.
03 - While the potatoes cook, heat olive oil in a large skillet over medium heat. Add the sliced onions and sauté, stirring occasionally, until deeply golden and caramelized, about 15 to 20 minutes. Add the minced garlic and cook for 1 additional minute until fragrant.
04 - Mash the drained potatoes together with the butter, warm milk, sour cream, salt, and black pepper until smooth and creamy.
05 - Stir half of the cheddar and mozzarella cheeses into the mashed potatoes. Fold in the caramelized onions, reserving a few tablespoons for the topping.
06 - Spread the potato mixture evenly into the prepared baking dish. Top with the remaining cheddar and mozzarella cheeses and the reserved caramelized onions.
07 - Bake for 25 minutes, or until the cheese is melted, bubbly, and lightly golden in spots.
08 - Garnish with fresh chives if desired. Serve hot.