Preheat the oven to 350°F (180°C). Grease a 9×13-inch (23×33 cm) baking pan with butter, then sprinkle with cocoa powder.
In a large bowl, whisk together the all-purpose flour, granulated sugar, cocoa powder, baking powder, baking soda, and salt until everything looks evenly combined and there are no visible streaks of cocoa or flour.
In a separate bowl or large measuring cup, whisk the eggs until the yolks and whites are well blended. Add the whole milk, vegetable oil, and vanilla extract and whisk until the mixture is smooth and slightly frothy.
Pour the wet ingredients into the bowl with the dry ingredients. Whisk gently, starting from the center and working outward, just until you no longer see dry pockets of flour.
Prepare the brewed coffee or hot water. Slowly pour the hot liquid into the batter in a thin stream while whisking constantly.
Transfer the batter to the prepared pan, smoothing the top with a spatula. Tap the pan gently on the counter a couple of times to release any large air bubbles.
Bake the cake on the center rack of the oven for about 25 to 30 minutes, or until the top springs back lightly when touched and a toothpick inserted in the center comes out with a few moist crumbs but no wet batter.
Remove the cake from the oven and place the pan on a wire rack. Let the cake cool in the pan for about 15 to 20 minutes.
Heat up the milk for 30 seconds in the microwave. Place the cocoa powder in a measuring cup with a spout. Whisk until fully dissolved.
Add the sweetened condensed milk, evaporated milk, and espresso powder if using. Whisk until the mixture is completely smooth and uniform.
Once the cake has cooled slightly but is still warm, use a skewer to poke holes all over the surface of the cake.
Slowly pour the chocolate tres leches mixture over the entire surface of the cake.
Cover the pan tightly with plastic wrap or foil and transfer it to the refrigerator. Chill overnight.
Once the cake has chilled, prepare the whipped cream topping. Place the heavy cream in a chilled mixing bowl. Add the powdered sugar and cocoa powder.
Beat the mixture with an electric mixer on medium speed until it begins to thicken, then increase to medium-high and continue beating until you reach medium to stiff peaks.
Add vanilla and mix briefly to combine.
Spread the chocolate whipped cream evenly over the top.
Keep the finished chocolate tres leches cake refrigerated until serving.
