You get the extra breaths because the ambient pressure around you decreases which allows you to inhale the remaining gas in the tank.. Your lungs must be capable of overcoming the surrounding ambient pressure, this decreases as you ascend which then allows you to inhale any remaining gas in the tank.
Several have however, given you incorrect information on regulator operation. When the pressure in the tank drops to the IP pressure of the regulator (around 135 psi/ 9 bar) plus ambient pressure, the reg does NOT stop allowing gas to flow through it, you can always get any remaining gas in the tank as long as you have the lung power to pull it out. Once the internal pressure of the tank reaches the regs IP plus ambient pressure (roughly 15 psi/ 1BAR per 33ft/ 1M) the HP valve of the reg opens fully and remains open until tank pressure is once again above IP + ambient. This can occur as you ascend but since you only get around 15 psi/1 bar for each 33 ft you ascend it's not much. As you breath the gas past the point where the reg is fully open (below IP plus ambient) , inhalation gets harder and harder with each breath but all of the remaining gas in the tank is accessible. This is because the IP is no longer being regulated but is now simply the amount of pressure in the tank above the surrounding ambient pressure. There are a number of flow restrictions in a regulator and without the assistance of the higher pressure, your lungs must supply additional energy to get the gas out.....it becomes harder to breath. It is also incorrect to say you can not "create a vacuum in your scuba system" it can in fact be done and can give you slightly more gas if you do. Breathing a tank down to slightly below 0psi (or pulling a slight vacuum) is possible. You can't pull much of a vacuum, just the amount your lungs can create over ambient pressure and certainly not a full vacuum but a slight one is possible. It's a small amount of gas and not something you should count on but "can't " is an incorrect statement...