It's like a climber who hammers in safety anchors on the way up. If you slip, you don't fall to the ground, only to the last anchor.
An example. You bought at $101, stop $98.5, target $107.5. The price reached $104 and made a new swing low at $102.5. You move the stop up under that swing low — to $102. Now, even if the price turns around, you'll close in profit. This kind of stop is called a trailing stop, because it trails behind the price.