The main problem with Nh4 is the fork with g5. You still have knight takes f5 but the main problem is after pawn takes. The oponent has too much activity I think. But it's only at the first glence, so I don't really know...
Why is this a Blunder?

Bxc2 Qxc2 g5 Bxg5 RxB maybe
and the computer's suggested move wins a pawn. I think blunders are 3 point differential (?) but its hard to nail down their scale. You are at -3 if you play your knight, and +1 if you take that pawn. Alternative, but not great, is Bxb8 RxB Nh4 as you did is safe now.
It's a blunder relatively speaking.
Nb5 gains tempo for white because black has to deal with the thread of Nc7.
White is in a great position after that.
Otherwise, Nh4 doesn't help white, and g5 opens the file and looks nasty for white.
This is pretty cool: https://decodechess.com
I paid for a month, but then decided I preferred analyzing my games with Lc0 and NIbbler. If I hadn't stumbled on that, I might still be using Decode.
My main complaint is they don't show multiple lines and let you see the decision tree. If they had that and minimized the time I had to wait to see calculations, I might still be paying for it.
Can someone explain to me when we can know that it's a blunder ?
Preferably, you will see it before you move, while checking out your choices. So the when is 'before you move'. The 'how' is harder... you need to be able to play out the moves in your head far enough to see if it is a mistake or not. I guess start here: do you see the pawn fork after the knight move?
You could be up one pawn instead of putting the knight on a square that doesn't do anything. Attacking the pawn starts with a pawn trade followed up by you taking the last pawn with your bishop. Moving your knight there encourages the opponent to move the bishop to defend one of the pawns.

To start off,
Here’s a two step «I don’t know what to play in this position» checklist that is easy to remember:
Is my king in any danger, or do I see an immediate threat? If no, have I developed all my pieces, or are they inactive?
Let’s use these two steps to analyze your position: First, black has no way to attack your king this moment, so for now it is safe. Does black threaten something else? Only their bishop and knight is in the game, but neither has a way to create any obvious danger, and neither can attack anything that is undefended.
Now that we know you are safe, are your pieces active?
Your light square bishop is stuck behind a wall of pawns and is unable to join the game. Also, your rook is sitting in the corner doing nothing. With this in mind, do you have an idea why the engine wants to take the pawn on c4?
Without checking with the computer I can argue that the engine likes taking pawn on c4 because it both opens up a file for your inactive rook and soon a diagonal for your bishop, solving both problems.
Now we have made sure that we are safe, and then found a solid way to get our inactive pieces into the game. You are taking no risks, just calmly improving your position.
Now moving on to more thoughts I have,
I (boldly) assume you played knight to h4 to attack blacks bishop, but he can just retreat and now your knight is on the rim of the board. If we look back to our previous ideas, we can now see that the bishop you are attacking is not a threat, and you also have inactive pieces.
We can also note that black has all their pieces on the back rank, completely inactive.
I hope I helped you make more sense of the situation and that I answered your question to some degree :)
To summarise,
In general, if you see no threats and you are not sure what to play, focus on improving your position. It is better to simply play a piece to a better square than to make a move without any reason.

To start off,
Here’s a two step «I don’t know what to play in this position» checklist that is easy to remember:
Is my king in any danger, or do I see an immediate threat? If no, have I developed all my pieces, or are they inactive?
Let’s use these two steps to analyze your position: First, black has no way to attack your king this moment, so for now it is safe. Does black threaten something else? Only their bishop and knight is in the game, but neither has a way to create any obvious danger, and neither can attack anything that is undefended.
Now that we know you are safe, are your pieces active?
Your light square bishop is stuck behind a wall of pawns and is unable to join the game. Also, your rook is sitting in the corner doing nothing. With this in mind, do you have an idea why the engine wants to take the pawn on c4?
Without checking with the computer I can argue that the engine likes taking pawn on c4 because it both opens up a file for your inactive rook and soon a diagonal for your bishop, solving both problems.
Now we have made sure that we are safe, and then found a solid way to get our inactive pieces into the game. You are taking no risks, just calmly improving your position.
Now moving on to more thoughts I have,
I (boldly) assume you played knight to h4 to attack blacks bishop, but he can just retreat and now your knight is on the rim of the board. If we look back to our previous ideas, we can now see that the bishop you are attacking is not a threat, and you also have inactive pieces.
We can also note that black has all their pieces on the back rank, completely inactive.
I hope I helped you make more sense of the situation and that I answered your question to some degree :)
To summarise,
In general, if you see no threats and you are not sure what to play, focus on improving your position. It is better to simply play a piece to a better square than to make a move without any reason.
Thank you so much for making such a thorough reply. It helped me tremendously.
Even though the game was a few days ago, I do remember moving the knight to irritate the bishop. I often find myself in these situations where I don't see an obvious move to make, so my logic will go to: "where can I move a piece that won't be in danger and may also make an opponent's piece uncomfortable?"
Your suggestion of looking at threats and development help me see this board much more clearly. Thanks again.

Thank you so much for making such a thorough reply. It helped me tremendously.
Even though the game was a few days ago, I do remember moving the knight to irritate the bishop. I often find myself in these situations where I don't see an obvious move to make, so my logic will go to: "where can I move a piece that won't be in danger and may also make an opponent's piece uncomfortable?"
Your suggestion of looking at threats and development help me see this board much more clearly. Thanks again.
Glad to help!

1. this is not actually correct
2. you are 2 days late
i am going to offer an alternative algorithm.
after the opponent's last move, ask yourself,
what is he/she trying to do with that last move? (if it is threatening to take or attacking something you need to address because otherwise you lose the game)
can i somehow take advantage of the square and or piece that my opponent's last move left undefended? (if it's a piece can i take it? if a square, can i now occupy it favorably?)
in the event that nothing is happening, then you can proceed to improve your pieces,
and before you play your chosen move, a safety net would be, "can my opponent now take advantage of the piece/square left undefended by this move i am choosing to play?" this is to minimize blunders if not prevent them altogether.
I find this part of chess to be the most difficult to get a grasp on. In the case above, what should I have looked for to know that c4 is a good move while Nh4 is a blunder?
In the larger picture, I find it really hard to learn from my mistakes because often times I don't even know I'm making them. Any suggestions on how to focus my study and practice so I can better understand my mistakes?