Preheat your oven to 350°F (175°C). Grease a 9×13-inch baking dish and set aside.
In a medium saucepan, add the sliced potatoes and enough water to cover them. Bring to a boil and cook until the potatoes are tender but not mushy, about 10 minutes. Drain and set aside.
In a large skillet, heat the olive oil over medium heat. Add the chopped onion and garlic, and sauté until the onion is translucent and fragrant, about 5 minutes.
Add the drained sauerkraut to the skillet and cook for another 5 minutes, stirring occasionally.
In a mixing bowl, combine the sour cream, mayonnaise, shredded cheddar cheese, shredded mozzarella cheese, and caraway seeds (if using). Mix well.
Layer half of the cooked potatoes in the prepared baking dish. Spread half of the sauerkraut mixture over the potatoes.
Spread half of the cheese sauce over the sauerkraut layer. Repeat the layers with the remaining potatoes, sauerkraut mixture, and cheese sauce.
Cover the baking dish with aluminum foil and bake in the preheated oven for 30 minutes.
Remove the foil and bake for an additional 10-15 minutes, or until the top is golden and bubbly.
Allow the casserole to cool slightly before serving.