First check whether your move is legal. Then imagine the new position and inspect the opponent's legal captures. A capture that looks useful may leave your own piece open to capture on the next turn.
Worked example
White's rook can move from d1 to d4 and capture a pawn. But the black bishop on g7 has the diagonal g7, f6, e5, d4. After the rook lands on d4, Black can capture it. The rook followed its rule, but the reply matters.
Compare Only the Next Reply
White has king a1 and rook d1. Black has king h8, bishop g7 and pawn d4. All other squares are empty; White moves first. Compare rook d1 to d4 with rook d1 to d3, resetting the position each time. d3 is not on the bishop's diagonal. The black pawn on d4 cannot capture straight ahead onto d3.