Place potatoes in a large saucepan and cover with 2 inches of water. Bring to a simmer over medium-high heat. Reduce heat to medium, partially cover and cook until tender, 10 to 15 minutes. Drain and return the potatoes to the pot. Add buttermilk, margarine and 1/4 teaspoon each salt and pepper. Mash with a potato masher until mostly smooth.
While the potatoes are cooking, position rack in upper third of oven; preheat broiler. Coat four 10- to 12-ounce broiler-safe ramekins (or an 8-inch-square broiler-safe baking dish) with cooking spray. Place ramekins on a broiler-safe baking sheet.
Heat oil in a large skillet over medium-high heat. Add onion, carrot and 1 tbsp water. Cover and cook, stirring occasionally, until softened, 3 to 5 minutes. Stir in corn, thyme and the remaining 1/2 teaspoon salt and 1/4 teaspoon pepper; cook, stirring occasionally, for 2 minutes. Sprinkle with flour and stir to coat. Stir in broth. Bring to a simmer; cook, stirring, for 1 minute. Stir in lentils and cook, stirring constantly, for 2 minutes.
Divide the hot lentil mixture among the prepared ramekins (or spread in the baking dish). Top with the mashed potatoes. Broil, rotating halfway through, until the potato is lightly browned in spots, 6 to 10 minutes.
Make Ahead Tip: Prepare the filling, cover and refrigerate for up to 1 day.
If cooking lentils:
Place in a saucepan, cover with at least 1 inch of water, bring to a simmer and cook until just tender, 15 to 30 minutes, depending on the type of lentil. Drain and rinse with cold water. 1 cup dry lentils = about 2 1/2 cups cooked. Or use canned lentils: 15-ounce can = 1 1/2 cups. Rinse canned lentils before cooking with them to reduce the sodium by about 35%.