The analysis board says it’s the 2nd best move. Game review’s always on some sort of drug, use analysis
Why is 10. Nxg6? a bad move here?
Taking on g6 is fine there.
It's a bit rushed, though (why take it now? That bishop's not going anywhere.)
Perhaps simply castle first.
Then, if Black plays ...Nbd7 (the most logical next move), you could then make a choice: take on g6, or drop the knight back to d3 to attack the b4 bishop.
Black's dark bishop is his "good" bishop, so arguably dropping the knight back to d3 would be the stronger move, as it threatens a more valuable piece to Black ...
If someone told you that taking on g6 there is "bad", they're probably suggesting that the g6 bishop is a bad piece, and taking it right away is simply relieving Black of it. Sometimes, it's better to let the opponent suffer with a bad piece, rather than exchange it away for them. But juggling these kinds of nuances can sometimes be more confusing than they're worth, if you pay too much attention to them ...
To put it more simply: there's really nothing wrong with taking on g6.
White's doing fine in any of these lines.
I understand why usually taking on g6 is bad since it allows hxg6, opening up the file for the Rook, but in this case, since black has already castled, he does not get this 'upside' but gets the supposed 'downside' of weakening his castled king since now a queen and rook on the h file could prove deadly.
In addition to weakening the black king by forcing hxg6 we also have two more minor advantages: the bishop pair and doubling of this pawns on the g file.