Preheat oven to 350°F (175°C). Grease and line two 8-inch cake pans. Whisk together flour, baking powder, and salt; set aside.
Cream butter and sugar until pale and fluffy, about 3–4 minutes. Add eggs one at a time, then stir in vanilla, lemon zest, and lemon juice.
Alternate adding the flour mixture with the milk and sour cream to the batter, beginning and ending with flour. Mix until just combined.
Divide batter between pans and bake 25–30 minutes until a toothpick comes out clean. Cool 10 minutes in pans, then transfer to wire racks to cool completely.
Cook raspberries, sugar, and lemon juice over medium heat until fruit breaks down, 7–10 minutes. Add cornstarch slurry if you want thicker compote. Cool completely.
Beat butter until creamy, add powdered sugar gradually, then add lemon juice, zest, and salt. Adjust consistency with more powdered sugar or lemon juice as needed.
Level cake layers if needed. Place one layer on a plate, spread half the compote, top with second layer, and frost with lemon buttercream. Chill briefly to set.