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. Mario, Luigi, or any other playable character in some Mario games have to jump and grab the Goal Pole to finish the level.
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. Flagpoles were replaced with boxed, roulette-like goals in Super Mario Bros. 3, and Giant Gates in Super Mario World. These Flagpoles symbolize Mario and friends taking over or claiming that area -- taking down Bowser's flag and/or replacing it with their own.
Super Mario series
Super Mario Bros. and Super Mario Bros.: The Lost Levels
In Super Mario Bros. and Super Mario Bros.: The Lost Levels, Mario can jump over the flagpole in certain levels (such as World 3-3). In Super Mario Bros.: The Lost Levels, however, Luigi can easily do so 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. If the player gets a 1, 3, or 6 on the timer in Super Mario Bros., they can get one, three, or six fireworks, each worth 500 points, depending on which number the last digit is. Grabbing the top of the flagpole in these games only rewards the player with 5000 points. 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 the same digit, basically) and the last digit of the timer must be that same digit when the player character touches the flagpole.
New Super Mario Bros. series
In New Super Mario Bros., Mega Mario or Mega Luigi can destroy the flagpole (They shrink into Super form and head into the fortress afterwards.), filling up one-fifth of the meter above them, ensuring at least an extra life is gained. Additionally, if the last two digits of the timer are same when the level is cleared, the Super Mario Bros. "Level Clear" theme is played instead of the normal one, fireworks go off (1 for ending in 11, 2 for ending in 22, and so on, awarding 4,000 points per explosion for a maximum of 36,000), and a bonus Toad House appears at the map's starting point. Time limits ending in 11, 22, or 33 yield a Power-Up Toad House, 44, 55, and 66 yield a 1-Up Toad House, and 77, 88, and 99 yield a Mega Mushroom Toad House. None of these houses are permanent, even after completing all of the levels in the game.
As of New Super Mario Bros. Wii, Bowser's emblem replaces the skull on the flag. Like in New Super Mario Bros., Toad Houses can appear at the starting points of worlds by using the same strategy. In multi-player mode, the strategy is exactly the same, but since there are no Mega Mushroom Toad Houses, Star Toad Houses appear when the time limit's last two digits show 77, 88, or 99, and the times for the Power-Up Toad House and 1-Up Mushroom Toad House are flipped. In single player mode, the strategy is slightly different. Instead of finishing the stage with the last two digits of the time limit being the same, if Mario or Luigi saves the Toad in the level and takes him to the end, only the last digit counts (e.g. 1, 2, and 3 make a 1-Up Toad House appear instead of 11, 22, and 33). Once again, these Toad Houses aren't permanent.
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. The Goal Pole can still be destroyed by Mega Mario or Luigi, but the player only gains three extra lives for doing so. If Mario is in his Gold form, he gains Coins upon grabbing the Goal Pole rather than points, like in Super Mario 3D Land. Additionally, hitting the top of the Goal Pole in Coin Rush mode doubles the round's accumulated coin total.
In New Super Mario Bros. U, getting double digits at the end of the time (i.e. 344) will give a reserve power-up (A Super Mushroom for x11, x22, or x33, Fire Flower for x44, Ice Flower for x55, Mini Mushroom for x66, Super Acorn for x77, or a Star for x88 or x99; nothing is given for x00.). In New Super Luigi U, when the player grabs the Goal Pole as Nabbit, they will receive 1-Up Mushrooms based on the amount of power-ups they collected. In certain Challenge Mode missions, the Goal Ring appears as the endpoint instead.
Super Mario 3D Land
The flagpoles, now called Goal Poles, appear in Super Mario 3D Land; their first appearance in a 3D Mario game. Unlike in 2D 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, he earns Coins instead of points, and 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 100% completion for the entire game. The normal Goal Pole flag is replaced by a giant Bowser flag in each castle and airship (and in Special 8-Crown), which turns into a giant Mario/Luigi flag once grabbed. 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, similar to Super Mario Bros. and Super Mario Bros.: The Lost Levels.
Super Mario 3D World
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), acting just like they did in Super Mario Bros.
Fake Goal Poles can 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.
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 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 dependent on how high the Goal Pole was struck, similar to Super Mario 3D Land.
Appearances in other games
Names in other languages