Here's the part most beginners skip, but we won't: Castling is a special one-time move: the king moves two squares toward a rook, and that rook jumps to the other side of the king. It tucks the king behind a wall of pawns โ but only if neither piece has moved and no pieces block the way.
Take your time and calculate before you move.