I was wondering how to ensure a win with a rook v. queen
Study it, then practice it. There's no trick to make it easier than that. There are a few standard positions such as the philidor (yes, he did more than the rook endgame) and the 3rd rank defense.
-
why in some positions it's not [a win]
Pawnless Q vs R is always a win. When the weaker side has a pawn, then sometimes it's a draw. When it's a win even in spite of the pawn then breaking down the false fortress is another technical endgame you'd study separately.
So I'm only 1200 rapid, and I don't really know how to play a rook versus queen endgame. I was wondering how to ensure a win with a rook v. queen, and why in some positions it's not (the game is attached below. There are a lot of blunders in the opening, middle game, and end game, but I was able to win).