Generally speaking, a piece is more active when it's on the opponent's side of the board. So attacking an enemy pawn from the back simultaneously allows the rook to eye other features in the enemy's position, which may include cutting off the enemy king from further ranks.
Additionally, when you compare positions, a rook is decidedly less active in a blockading position. Other than not eyeing any other enemy pawn or square, the rook also gets in the way of other friendly pieces that have to maneuver around it.
When supporting your own pawn, it's good behind because the rook itself won't obstruct the pawn's path to the queening square. If the pawn is blockaded the supporting rook may be deemed passive, but because passed pawns are such a prominent / dangerous feature of a position, this sort of supporting role is often very effective for the friendly rook, even if it's doing little else than helping the pawn advance.
Whether the pawn is friend or foe, the rook will have more available sqaures each time the pawn advances. A rook in front of a pawn will only lose mobility as the pawn moves closer to queening.
Why Rooks should be placed behind passed pawns – your pawns or your opponent’s pawns in the endgame?