Peel, core, and dice the apples into small, even pieces. Keeping them relatively small helps them soften quickly and makes the pastry squares easier to eat.
Melt the butter in a skillet over medium heat. Add the diced apples, brown sugar, cinnamon, nutmeg, and a small pinch of salt. Cook for 5–6 minutes, stirring occasionally, until the apples begin to soften but still hold their shape.
In a small bowl, whisk together the cornstarch and water until completely smooth. Pour the mixture into the skillet and stir continuously for about 1 minute, until the apple juices become thick and glossy. Remove from the heat and stir in the vanilla extract. Let the filling cool completely before placing it on the puff pastry. This is important because hot filling can soften the butter layers in the pastry and reduce its rise.
Preheat the oven to 400°F (200°C) and line a large baking sheet with parchment paper. Unfold the cold puff pastry on a lightly floured surface and gently roll it out if necessary. Cut it into 6 equal squares. Using a small sharp knife, lightly score a smaller square inside each piece, leaving approximately a ½-inch border around the edges. Don’t cut completely through the pastry.
Transfer the pastry squares to the prepared baking sheet. Spoon the cooled cinnamon apple mixture into the center of each square, keeping the filling inside the scored border. Drizzle a small amount of caramel sauce over the apples. If using chopped pecans or walnuts, sprinkle a few over each pastry.
Whisk the beaten egg with 1 tablespoon of water. Lightly brush the exposed pastry borders with the egg wash, being careful not to let too much drip down the sides.
Bake for 18–22 minutes, or until the puff pastry has risen dramatically and the edges are crisp and deeply golden. The apple filling should be bubbling slightly in the center.
Let the pastries cool on the baking sheet for about 5 minutes. Drizzle the remaining caramel sauce generously over the warm apple squares. For a salted-caramel version, finish with just a few flakes of sea salt. Serve warm and freshly baked, either on their own or with a scoop of vanilla ice cream.