From the Super Mario Wiki
A Pyramid is a large structure built of stone or mud brick. Many of them can be found in Egypt.
Pyramids have also appeared in the Mushroom World. There is one placed called Pyramid in Mario Party Advance. It is located in the Desert Area of Shroom City. The only way to get there is by going to The Hammer and playing its game. Here, the player will meet Kamek, the Game Mage. His quest, "Game Mage", involves the player playing Kamek's game, Pair 'Em. If the player wins, Kamek will accept them as a great gamer, and lets them keep his game.
In Super Mario Land, level 1-3 (which is the last area of the Birabuto Kingdom and the place where the kingdom's boss King Totomesu lives) is set inside of a pyramid. Also, some pyramids can be seen in the background of level 1-1.
A pyramid also serves as the main setting of the Club Nintendo comic "Mario's Picross". After Mario accidentally has broken off the Sphinx' nose, he gets imprisoned inside of a pyramid. He comes across several traps, including a Chomp Rock and a trap door, when trying to escape out of the building. Mario also discovers a treasure chamber inside. Finally, a lorry takes him out of the pyramid.
Pyramids are also prominent in World 2 and World 6 of Super Mario Bros. 2, which are both desert-themed worlds. In some instances, the player will have to venture inside a pyramid in order to proceed.
In Desert Land in Super Mario Bros. 3, many pyramids can be seen in the backgrounds of certain levels. Level 2-3 in particular has many diminutive pyramids made up of Brick Blocks. There is also an entire pyramid level located right next to Desert Land's castle. Pyramids can also be seen in the backgrounds of desert-theme levels 7-2 and 7-9 of Pipe Land.
The Great Pyramid of Giza is one of three landmarks in Cairo Luigi visits in the game Mario is Missing!. It is the largest pyramid in the city, and Koopa Troopas stole its top brick. In order to find his brother, Luigi needs to find the brick and return it to the pyramid. The game also provided information about the Great Pyramid, e.g. that it is 480 feet high and covers 13 acres of desert, and about pyramids in general.
In the Super Mario 64 (DS) level, Shifting Sand Land, a giant pyramid can be found in the center of four pillars. It houses Grindels and Spindels, mummy variants in the Thwomp family. An Eyerok guards the world's Power Star, and can only be reached and battled via a secret passage within the pyramid.The place is also full of quicksand.
Although none can be entered, many pyramids can be seen in the background throughout many desert regions of the Mushroom World, including World 2 in New Super Mario Bros., Pyramid Park and racecourses such as Dry Dry Desert, Dry Dry Ruins and Yoshi Desert.
In the Dusty Dune Galaxy of Super Mario Galaxy, despite being a desert galaxy, there are initially no pyramids to be found. However, by finding and feeding a Hungry Luma 20 Star Bits, it will transform into a planet in the shape of two pyramids attached together at their bottom ends. By venturing into the pyramid planet and collecting the five Silver Stars within, Mario will be rewarded with a Green Power Star. A pyramid also appears in Slipsand Galaxy in Super Mario Galaxy 2. Though the pyramid itself is not visited, there is a stream of sand coming out of it, which the player must slide down while avoiding Rhomps, which come from behind them. The pyramid can also be seen on the World 5 map, representing the galaxy.
There is even a desert-themed land by the name of Pyramid Land, which is home to numerous pyramids. During the events of "The Ten Koopmandments", Mario and his friends are trapped in one of Pyramid Land's pyramids after Koop Tut sealed them in. After evading a Goomba Mummy, a Cobrat and a Phanto, Mario's group escape upon discovering an emergency exit slide.