Why is castling here a mistake? I am back at chess after two years and am enjoying it a lot. I was playing and this happened after I checked a report at chess.com:

I have googled the importance of when to castle the king. Here I know castling isn't the best move, but why is it a mistake?
The engine is giving you an answer. Black plays ... Na5 followed by ... Nc4 which prevents White from bringing pieces over to the queenside, because of the White doubled pawns on c2 and c3. Which means the White king is now stranded by itself on the queenside.
Black is going to play ... c5 and bring the queen out to a5 or b6. On a5 it threatens ... Qxa3 with mate to follow. On b6 it's threatening ... Qb2 with mate.
What queenside castling has done is to put the White king into the line of fire, in a way that Black has at least two pieces converging to attack, and White has none. Even, if by miracle, White gets some pieces over to the a- and b-files, Black's other pieces will enter the fray much quicker and in much larger numbers: The a8 rook by pushing the a-pawn, the c8-bishop via d7.
The chess engine reckons White is going to lose at least a rook to stave off this attack (this is simply the difference between the position evaluation after queenside castling -6.27 versus the best move Nf3 which is evaluated to -1.74).
In logical terms, you castled into an attack on the queenside. With the centre as constricted as it is, your king was fairly safe remaining in the centre uncastled for the time being. You needed to develop the Knight to f3, and the bishop to e2, and take it from there.