lichess.org/training/86198Is the reason Nxf4 is correct because even though Nxh8 leaves you up the exchange the knight is trapped in the corner?
The knight isn't leaving the corner. And an extra piece is more than the exchange.
It's not the reason, surprisingly. Something like Nxh8 Bd6 Nd2 Ke7 Nxf7 Kxf7 is just as good for white as Nxf4, as white has a strong attack. (Edit: and being up an exchange and a pawn isn't meaningfully worse than being up a piece).
The problem is Nxh8 d4! and the threat of Qf3 is unstoppable (Qd1 Ne5; f3 Qxb2 -+). Black then has a perpetual check with Qxg4+, or even a win with Qh3 if white makes another mistake.