There are a couple things here.
Reality is hard to get on camera.
Many movies have unrealistic physics to show the audience how close it really was. For example, in a fighter jet trying to avoid a modern missile, the pilot will likely never physically see the missile unless it's close enough the pilot doesn't survive. But that doesn't show up well on camera, so the producers create a highly caricatured scene with missiles dancing on the aircraft's tail that tells the audience how touch-and-go the situation is. I'm not sure if this has a particular "trope" name, but it's a form of artistic license.
In your (first) example case1, we might depict the spaceship being beneath the skyscraper tops when it finally pulls up, even though a real object plummeting at the depicted speeds might require thousands of feet to pull out of the dive. It's not a lie -- it's just a way of showing "truth" so the average viewer gets it.
Reality is boring.
We often see gross exaggeration and hyperbole, just because it's cool. TVTropes calls it the rule of cool (and is another form of artistic license), but it can also be used for specific people to show just how skilled they are compared to normal people.
In your example case, the jet/spaceship/whatever may get close enough to literally graze the frothing waves or kick up the dust from the desert plains, even though that's ridiculously unlikely to happen by accident, and even Captain Kirk wouldn't be skilled enough to pull out of the dive at the exactly correct moment to touch the ground without hitting it.
You need time to create tension.
You'll often see sequences that should have taken 3 or 4 seconds, but are extended to tens of seconds, if not minutes. Yet another form of artistic license (that sometimes falls under rule of cool), the idea here is to slow things down so the uninformed audience can fully appreciate the gravity of the situation and get emotionally invested in the outcome before the outcome is revealed.
In your example, the crew may have time to run from one end of the ship to the other even though external shots (and/or speed indicators on internal displays) clearly show they didn't have enough time. They may have entire conversations or "it was good knowing you" speeches. In order to make this seem a little more plausible, they often use every bit of real estate (sometimes re-using a couple shots from different angles and hoping you don't notice), which results in the ship pulling up "at the last second" 30 seconds after the last second.
(One of my pet peeves on this one is the "No! You don't have time to save me! Go on without me!" arguments that take four times longer than it would have taken to just go back and save them.)
Tolkien invented a word for this when it involves the entire story.
Tolkien created the term eucatastrophe (literally, a good unraveling of the plot) to refer to a case where the entire storyline is brought to a point where the good guys just can't win. Then suddenly a plot device enters and saves the day. This often overlaps with a deus ex machina device, but doesn't have to. It's also a darkest hour type of trope.
In your example, it's not just the Enterprise crew at stake here; the Borg/Xindi/whoever have been at the throats of the Federation for the last half of the season, they have the alphaomegagigasupersayan doomsday device, half the crew is dead, and the only hope is for the Enterprise to launch a special proton torpedo at the doomsday device from point-blank range. They've been hit, are falling, Scotty's unconscious, Kirk's out of commission, Spock was kidnapped two episodes ago and is nowhere to be seen, and the ground station that was planning to use force fields to catch the Enterprise just took a sucker punch from an antimatter bomb. All hope is lost. First, Earth, then the Federation. Abandon all hope, ye who live here.
Then McCoy remembers a serum that reverses the alien blood plague, revives Kirk, Scotty wakes up and realizes the transducer overlay can be connected to the thruster alignment matrix to boost the impulse engines long enough to get the ship lined up for the shot. Ahura gets a comm signal from Spock who calmly suggests the Enterprise hurry up so they can use the opening he just created. Pew pew pew, kerrrshhhplode, happily ever after.
This is an extreme version of building tension, and can be difficult to get right. One man's "on the edge of my seat" is another man's "eww, just get on with it already".
1I'm not completely familiar with this exact scene, so I'm going with the general cases that appear a few times in Star Trek.