advice for how to stop losing rooks


In the above example, 9...O-O? is a bad move that immediately dooms the rook. Instead, the correct move to play is g5 (g6 also works), then Rg8 after the bishop takes it. You should then resume your normal development and (probably) try to play O-O-O instead.
On a different note, it's important to give your rooks breathing room. They're usually the last pieces to come out and play, but they're also typically placed in open spots where they may be harassed a lot to make them move around. You should also be mindful of your king's location, especially if your opponent still has a knight, because not paying attention in that regard can cause you to accidentally drop them as well.

In the above example, 9...O-O? is a bad move that immediately dooms the rook. Instead, the correct move to play is g5 (g6 also works), then Rg8 after the bishop takes it. You should then resume your normal development and (probably) try to play O-O-O instead.
On a different note, it's important to give your rooks breathing room. They're usually the last pieces to come out and play, but they're also typically placed in open spots where they may be harassed a lot to make them move around. You should also be mindful of your king's location, especially if your opponent still has a knight, because not paying attention in that regard can cause you to accidentally drop them as well.
Thing is, if you play g6, it significantly weakens the dark squares around the kingside, and g5 is kind of an awkward move. The way to prevent it also depends on the opening, as sometimes you can play Ne1 or Ne8 to protect the pawn

This is too vague. No one will be able to help unless you show some games where that happened.