It controls which element is “on top” visually when they happen to overlap, right? Right. But there is more to the stacking order, much of which you can’t control. You can control stacking contexts though, which kind of reset the playing field within them, but themselves can be stacked. Steven Bradley explains.
Related: Jake Archibald also encountered this and has a little more info. Paul Lewis explains how this (kinda sucky) situation is unique to the web. Philip Walton explains yet another way.