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. Cook until fork-tender, about 15–18 minutes. Drain thoroughly.
03 - While the potatoes cook, heat olive oil in a large skillet over medium heat. Add the thinly sliced onions and sauté, stirring occasionally, until deeply golden brown and caramelized, about 15–20 minutes. Add the minced garlic and cook for 1 additional minute until fragrant.
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 - Stir half of the cheddar and mozzarella cheeses into the mashed potatoes. Fold in the caramelized onion mixture, reserving a few tablespoons of onions for the topping.
06 - Spread the potato mixture evenly into the prepared baking dish. 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.