Find the tabs
Look at the short ends of the box. You'll see a small perforated triangle or semicircle, often labeled 'Press Here to Lock Roll.'
The thing on your foil box you never pressed
The tabs on a foil box are easy to miss. Push them in, and they hold the roll's cardboard core so it spins without jumping out.
Quick answer
They're called end locks. Push the perforated tab on each end of the box inward and it pokes into the hollow cardboard core of the roll, pinning it in place like an axle. The roll can still spin freely, but it won't slide out of the box when you pull the foil. Reynolds Wrap even prints 'Press Here to Lock Roll' on the tab in plain text. Almost nobody reads it.

Official name
End locks
How it works
Pokes into the hollow cardboard core
Roll still spins?
Yes, just stays in the box
On plastic wrap too?
Yes, same design
The thing on your foil box you never pressed
The same end lock tabs appear on most boxes of cling film and plastic wrap. Same mechanism, same purpose. Plastic wrap is even more annoying when the roll flies out, the tabs are even more useful there.
Myth vs Reality
Run your thumb along the short end of a foil box. You'll feel the perforation around the tab. It's designed to detach from the box face and press through into the roll core.
Continue learning

You thought it was just for draining
Another kitchen tool feature hiding in plain sight that most people have never used correctly.

That hole you've been using as a hook
Another cookware design detail with a more useful second function.

That weird mark you've been ignoring
Another everyday tool with a hidden feature people overlook for years.