Preheat the oven to 350°F (175°C). Grease a 9x13-inch baking pan.
In a medium bowl, whisk together the flour, baking powder, baking soda, and salt. Set aside.
In a large bowl, cream the softened butter and brown sugar together until light and fluffy. Add the egg and vanilla extract, mixing until well combined. Stir in the mashed bananas.
Gradually add the dry ingredients to the wet mixture, mixing until just combined. If using, fold in the chopped walnuts.
Pour the batter into the prepared baking pan and spread it evenly. Bake for 25-30 minutes, or until a toothpick inserted in the center comes out clean. Allow to cool completely in the pan.
For the caramel frosting, melt the butter in a saucepan over medium heat. Stir in the brown sugar and milk, bringing the mixture to a boil. Let it boil for 2 minutes without stirring. Remove from heat and let cool slightly.
Gradually whisk in the powdered sugar and vanilla extract until smooth. Spread the caramel frosting over the cooled banana bars.
Cut into squares and serve.