Think of it as a beer bottle and blowing over the top of it. The neck of the bottle is the port and the inside of the bottle is the net volume of the enclosure. When you blow over the top of the bottle, you push the column of air that is in the neck of the bottle down into the mass of air that is in the bottle itself. This volume of air has a spring force to it and as the column of air in the neck compresses it, it pushes back against the air in the neck. The force that you create by blowing the top of the bottle then pushes the air in the neck back down into the bottle. These two forces create an oscillation in the column of air and this creates a sound as it resonates. This gives you the tuning frequency of the enclosure. A neat little experiment can be done to hear the tuning frequency can be done with the sub out of the enclosure and a leaf blower. With the blower positioned correctly, you can get the enclosure to resonate at the tuning frequency.
Ported enclosure theory is based off of Helmholtz resonance. If you want to know more about where it comes from and how it's used, google it.