Legally you could castle in either direction, but which one is better (if you want to castle at all) is a decision in itself and the answer is "it depends." Usually Kingside castling is a bit safer and Queenside castling a bit more ambitious, but other elements also matter such as the fact that when both sides castle to opposite sides of the board, aggressive pawn storms are common.
I actually created a YouTube video on my chess channel regarding what side to castle in chess. I also give real examples to help convey the thought-process in how to approach which side you might want to castle:
Hello Chess.com enjoyers. I have one question, as you may read the title it's about castling. Do you castle queen side or king side???