From the Super Mario Wiki
A Goal Pole (originally known as a Flagpole) appears at the end of every normal level in most of the mainstream Mario games.
The flags on a flagpole come in many colors, though Red Flagpoles usually indicate an alternate exit in the New Super Mario Bros. games. If the player manages to grab the top of the flagpole, they will earn an extra life. However, in Super Mario Bros.: The Lost Levels, the player can receive an extra life from a flagpole only if two conditions are met: The coin counter must be 00, 11, 22, etc. (two of same digit, basically) and the last digit of the time counter must be that same digit when the player character touches the flagpole. In New Super Mario Bros. Wii, there are Bowser symbols shown on the flags instead of skulls. In Super Mario Bros. 3 there are Card Roulettes instead of flagpoles and in Super Mario World, flagpoles were replaced by Giant Gates. These Flagpoles symbolize Mario taking over or claiming that area -- taking down Bowser's flag or replacing it with his own.
Mario, Luigi, or any other playable character in some Mario games have to jump and grab the Goal Pole to end the level. In Super Mario Bros.: The Lost Levels, Luigi can easily jump over the flagpole due to his better jumping abilities. In order to still finish the level, he has to jump at it from the other side. It is unknown whether or not this is a glitch, as it does not cause any errors. It was not fixed in Super Mario All-Stars. In New Super Mario Bros., while being Mega Mario or Mega Luigi, they can knock over the flagpole, and then shrink into their regular form and head into the castle. By doing this, they end up earning five extra lives. If the player gets a 1, 3, or a 6 in Super Mario Bros. and Super Mario Bros.: The Lost Levels on the timer, they can get 1, 3, or 6 fireworks, depending on which last digit is earn.
Mario could also jump on Goal Poles (still called Flagpoles) in Dance Dance Revolution: Mario Mix, in the Flagpole Leap minigame. This game answers the question, "Why jump on the flagpoles?". The answer is, "Why not?".
They also appear in the Bowser inter-missions in Paper Mario: The Thousand-Year Door; Bowser can knock the pole completely off screen if he is large enough. In Mario & Luigi: Superstar Saga, there is a flagpole in front of the Little Fungitown that can be slid down on in the Beanbean Kingdom. A flagpole is also seen in the Super Mario Bros. picture behind the Border Bros..
Goal Poles appear in Mario & Luigi: Bowser's Inside Story when the Mario brothers or Bowser gain experience points.
Goal Poles also appear in the Nintendo 3DS game Super Mario 3D Land; the first appearance under that name. Unlike previous Mario games, Goal Poles appear in every level, even in castles and airships. After defeating the boss of an airship or castle, Mario has to keep walking to the Goal Pole instead of ending the level immediately after defeating the boss, as in previous games. When Mario grabs any part of a Goal Pole, a red flag with Mario's emblem (or a green flag with Luigi's emblem if playing as Luigi) replaces the one with Bowser's emblem. However, if Mario grabs the top of a Goal Pole, he will earn an extra life, and the flag will turn golden instead. These golden flags are required for completing 100% for the entire game. The normal Goal Poles are replaced by Goal Poles with giant Bowser flags after each boss battle or castle, and Special 8-Crown, which turns into giant Mario flags once grabbed, and Mario runs in circles and jumps happily as the different jingle plays. If Mario grabs the pole when the last digit on the timer is a 1, 3, or 6, streamers, fireworks, or balloons, will appear respectively as "COURSE CLEAR!" is displayed.
Goal Poles are also used in Mario Tennis Open, where they appear in the Super Mario Tennis mode. The Goal Pole can be hit by a tennis ball, and will end the mode in success, also offering a varying amount of coins dependant on how high the Goal Pole was struck.
In New Super Mario Bros. 2, getting double digits the same as the world number (i.e. the timer has to be x11 when in World 1) at the end of the timer means that a Rainbow Course will appear on the map.
New Super Mario Bros. U gives the player bonuses for completing the level at certain time markers. If the player finishes a level with double digits at the end of their time (i.e. 344), a Power-Up will be given. These Power-Ups are listed below. In New Super Luigi U when the player reaches the Goal Pole as Nabbit they will receive 1-Up Mushrooms based on the amount of power-ups they collected.
Goal Poles return in Super Mario 3D World. They function the same as in Super Mario 3D Land. However, in this game, hitting the top of a Goal Pole gives the player 10,000 points rather than an extra life. Again, hitting the pole will make a colored flag with an emblem appear for a character (red for Mario with the letter M, green for Luigi with the letter L, pink for Peach with a crown, blue for Toad with his face, cyan for Rosalina with a Grand Star, or gold for hitting the top). If the timer ends in 1, 3, or 6, then fireworks will appear in addition to the "Course Clear" message (except for The Great Tower of Bowser Land). Also, fake Goal Poles can also be found in Ghost Houses; touching these reveals that they are actually swarms of Boos, which promptly disappear. Another type of Goal Pole appears in The Great Goal Pole and Back to Hands-On Hall. In the former, the Goal Pole appears at the beginning of the level and flies away when the player approaches it. In the latter, the Goal Pole can be seen flying back and forth at the end of the stage.
Appearances in other games
Names in Other Languages