Speed, often abbreviated as SPD, is a type of internal variable that represents how many units Mario moves per frame. There are many speed variables, such as Horizontal Speed (HS), Vertical Speed (VS), X/Y/Z Speed, Sliding Speed, and X/Z Sliding Speed. These variables do not always represent how much Mario actually moves per frame; for example, when something is in his way, Mario can have horizontal speed without going anywhere. See De Facto Speed for more.
When airborne, Mario's vertical speed decreases by 4 units every frame due to gravity, and is capped at -75 units per second.
The speed variables are normally updated every frame, but sometimes this is not the case. When outside of water and not sliding, Mario's sliding speed is constantly updated to whatever his horizontal speed is, and when in water, Mario's sliding speed isn't updated at all. Therefore, horizontal speed can be conserved by going into water and entering a sliding state on the same frame Mario exits (for example, by pressing Z to crouch) to activate his sliding speed.
Negative Speed Buildup
The main reason why Mario is able to get massive amounts of negative speed so easily, is because although the game developers capped Mario's positive speed, they forgot to give a cap to negative speed, allowing Mario to get hundreds, thousands, or even millions of units of speed with tricks such as the Backwards Long Jump, Hyperspeed Walking and Backward Shell Hyperspeed. This slight oversight is the main root of many speed-gaining tricks in the game.
The maximum amount of negative speed Mario is able to build up is approximately -3*10^38. At higher speeds, Mario's intended next position increases beyond the highest finite value the game can store his position in, and the game crashes.