Preheat the oven to 200°C (400°F).
Boil the potatoes in salted water until tender, about 15-20 minutes.
In a skillet, melt butter and sauté onion and garlic until soft.
Add carrots and cook for 5 more minutes.
Stir in the ground meat and cook until browned, about 10 minutes.
Season with salt, pepper, and thyme.
Drain the potatoes and mash them with milk and butter until smooth.
Spread the meat mixture in a baking dish.
Top with the mashed potatoes and smooth the surface.
Sprinkle cheese on top, if using, and bake for 20 minutes until golden.