How does a third party candidate play the role of spoiler in an election?

The third party candidate endorses (supports) one of the major party candidates, causing the opponent to win

The third party candidate takes votes away from one of the major party candidates causing their opponent to win

The third party candidate drops out of the race, eliminating their own chance of winning the election.

The third party candidate wins the election​