Castles are a common type of level in the Mario series. Usually found at the end of each world, castles are usually where the heroic plumber and his allies confront the world's boss before moving on to the next world. Besides housing the boss, castles also tend to be rather hazardous places, with lava being more frequently found in castles than in most other areas in the series.
Super Mario series
Super Mario Bros.
In Super Mario Bros., castles are made of red bricks and all of them have the same basic shape. The castles can be found at the end of each world, and inside the player will encounter a False Bowser; defeating the false Bowser will allow Mario or Luigi to free a Mushroom retainer, who utters the infamous line "Thank you Mario! But our princess is in another castle!". It is only in World 8's castle that the Mario brothers actually confront the Koopa King himself, and defeating him allows the heroic plumbers to finally rescue Princess Toadstool.
Super Mario Bros.: The Lost Levels
As Super Mario Bros.: The Lost Levels is almost identical to Super Mario Bros. in terms of gameplay, castles play the exact same role in this game, and even look almost exactly the same as they did in their predecessor. However, Bowser can now be confronted in two of the game's castles rather than simply the last one.
Super Mario Bros. 2
Castles are fairly sparse in Super Mario Bros. 2, with only one genuine castle making an appearance. This castle is located in the clouds, and is inhabited by the game's final boss, Wart, who had captured it from the King of Subcon. This castle is unique amongst most castles in the Mario series in that it looks more like a palace than a simple, lava-flooded citadel.
Super Mario Bros. 3
Castles in Super Mario Bros. 3 are found at the end of every world, but function completely differently than their predecessors do. Instead of housing the boss, each of the first seven castles will house one of the kings of the Mushroom World who had just been turned into an animal by one of the Koopalings. After speaking to the Toad accompanying the king, Mario/Luigi will board one of the Koopalings' Airships, where they will confront the Koopaling in battle. Defeating the Koopaling will cause Mario to fall into to the castle with the wand in hand, where he is greeted by the newly restored king and given a letter from Princess Peach.
The last castle - Bowser's Castle - is a typical citadel-esque castle like the original Super Mario Bros., containing lava and a variety of traps. The level ends with a battle against Bowser, after which the Mario Bros. can rescue Princess Peach and finish the game. In addition to castles, a new level type called a Fortress appears which functions similarly to a castle: these fortresses always end in a battle against Boom Boom, who must be defeated in order to access some areas of each world.
Super Mario World
Like most of its predecessors, Super Mario World, castles will be found at the end of each world, where Mario will confront the world's boss - usually one of the Koopalings. Yoshi cannot enter castles, as shown in the cutscene at the beginning of each castle; this forces Mario or Luigi to head to the boss without him. The technical reason of why this happens is that Yoshi is not compatible with some enemies inside the Castles, notably Podoboos.
After Mario has defeated one of the Seven Koopalings, he will save a single Baby Yoshi and destroy the castle after exiting it. After the cutscene, Mario proceeds to the next world, giving the player a chance to save the game. The castles cannot normally be revisited in this game, only being replayable if the player holds both the "L" and "R" buttons at the same time while on the castle on the world map.
Super Mario 64 / Super Mario 64 DS
New Super Mario Bros.
After a long hiatus, Super Mario bros.-esque Castles finally made a return in New Super Mario Bros.. In this game, castles function similarly to how they had in prior 2D Mario games, being a dangerous, usually lava-flooded level that ends in a boss. A variety of boss enemies appear in these castles, from Petey Piranha to Bowser himself.
The beginning of the game also features Peach's castle, which is struck by lightning and ignited in the opening cutscene. While Mario is running off to investigate this mishap, Bowser Jr. appears and kidnaps Peach, forcing Mario to abandon the castle and give chase to the Koopa prince. The castle thereafter serves as part of the scenery of the first world.
New Super Mario Bros. Wii
Castles in New Super Mario Bros. Wii work in a similar way to how they acted in the game's prequel. Mario and his allies traverse a dangerous, usually lava-filled area before having a rematch with one of the Koopalings; before the battle begins, Kamek appears and uses his magic to alter the battle in ways to make Mario's battle more difficult, such as increasing the size of Lemmy Koopa's ball or flooding Wendy O. Koopa's boss room. The final castle pits Mario and co. against Bowser, who is fought similarly to the original Super Mario Bros. Upon his defeat, Kamek appears again and uses his magic to turn Bowser giant, forcing the heroes to flee from the revived Koopa king for the rest of the stage.
Super Mario 3D Land
Castles also appear in Super Mario 3D Land. They once again serve as locations where bosses are fought, but unlike prior games are only found in four of the main eight worlds; one each in Worlds 1 and World 5, and two in World 8. The first two castles in the game are home to two False Bowsers, while both in World 8 are Bowser's castles, and pit Mario against the Koopa King himself. In the Special Worlds, castles appear more prominently; however, they are almost always time trials, giving the player 30 seconds to complete. Dry Bowser resides inside the Special 1, Special 5, and Special 8 castles. Also unlike prior games, all the castles in this game have a giant Flagpole at the end.
New Super Mario Bros. 2
Castles, along with Towers, return in New Super Mario Bros. 2, acting much like it did in the prequels. The Koopalings appear as the bosses only in the Castles, as the Fortressses are occupied by Reznor. A hidden block containing a Super Leaf can be found at the end of every castle before a Koopaling battle, with the exception of Lemmy Koopa's Castle, which has a Fire Flower in a hidden block at the end.
New Super Mario Bros. U
Castles, and Towers return yet again in New Super Mario Bros. U, acting much like it did in the previous New Super Mario Bros. titles. However, the path to the bosses are different. Mario and co. have to now shoot themselves out of a cannon to reach the airships the Koopalings reside in.
Super Mario 3D World
Castles appear in Super Mario 3D World, similar to Super Mario 3D Land and the New Super Mario Bros. games. Only some bosses have castles before them, however - other bosses have either a different kind of stage before the boss fight, or have the whole stage dedicated to the boss fight. Once again, the Goal Pole can be found after defeating the boss, in contrast to most of the 2D Mario games. The seventh world of the game is also named "World Castle".
Mario Kart series
Several of the racecourses in the Mario Kart series have had castles, either as part of the course or as part of the background. The most prominent castle in the sub-series is Bowser's Castle, as it appears as one of the courses in every game in the series.
Peach's Castle has also had some appearances in the series. The Royal Raceway track of Mario Kart 64 features the castle, but in the background. In Mario Kart: Super Circuit's Rainbow Road, the castle can be spotted on top of Bowser's Castle, like in Paper Mario, in the background. In Mario Kart: Double Dash!!, it appears on Mario Circuit and vaguely on Mushroom Bridge, but also as part of the track's background. The back of Peach's Castle is featured in Mario Kart DS, on the Peach Gardens course. In Mario Kart Wii, the castle once again appears in the background of Mario Circuit. Mario Kart 7 also features Peach's Castle (once again on Mario Circuit), although this time it is a part of the track and the player is able to drive up a windy path inside of the castle.
Super Mario World 2: Yoshi's Island / Yoshi's Island: Super Mario Advance 3
Like in most other games, the castles in this game are found at the end of the World the Player is in. However, the creature found at the end usually does not intend to harm Baby Mario and Yoshi, until Kamek comes, and transforms it into a huge boss for the Player to fight, trying to slow down or even stop Yoshi from reaching Baby Bowser's Castle. Once the player gets to Baby Bowser's castle, even though it is guarded by Kamek, the player does not get to fight Kamek; instead, the player will fight Baby Bowser, powered up with Kamek's magic.
Super Mario RPG: Legend of the Seven Stars
Paper Mario series
A castle of some form appears in the end of almost all the chapters of Paper Mario and its sequels.