Keep in mind that your vehicle must be in Park and unlocked for this to work. As soon as you lock your vehicle, or put it in Drive, the gas tank door will stay locked.
Once you get the door open, simply twist the fuel tank cap to the left to remove it. Pump your gas, replace the cap by twisting it to the right until it clicks into place, and press the door closed until it is sealed.
If you have issues opening your gas tank door—and you’re sure that your BMW is in Park and unlocked—you’ll need to contact a mechanic or your BMW dealership for assistance.