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 over high heat, then reduce to a simmer and cook until fork-tender, 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 brown and caramelized, 15 to 20 minutes. Add the minced garlic and cook for 1 additional minute until fragrant. Remove from heat and set aside, reserving a few tablespoons of onions for the topping.
04 - Return the drained potatoes to the pot. Add the butter, warm milk, sour cream, salt, and pepper. Mash until smooth and creamy, ensuring no large lumps remain.
05 - Fold half of the cheddar and mozzarella cheeses into the mashed potatoes, followed by the caramelized onion mixture. Stir gently until evenly distributed throughout.
06 - Transfer the potato mixture to the prepared baking dish, spreading it into an even layer. Scatter the remaining cheddar and mozzarella cheeses over the top, along with the reserved caramelized onions.
07 - Bake uncovered for 25 minutes, or until the cheese is fully melted, bubbly, and lightly golden in spots.
08 - Remove from the oven and garnish with fresh chives if desired. Allow to rest for 5 minutes before serving hot.