Both are the result of the difference in the solubility of gas in liquid versus a solid.
Generally, the solubility of gases such as carbon dioxide, nitrogen, or hydrogen, is much higher in a liquid than in a solid. While in the liquid state the gas is in solution, but as the liquid cools and starts to solidify the gas comes out of solution and attempts to escape into the surrounding environment (air). Any gas that fails to escape before solidification is complete manifests itself as a bubble of gas entrapped in the solid. The shape of the bubble is dependent on the volume and rate of solidification.
In welding the presence of porosity can be seen visually when the gas bubble breaks the surface of the solidifying metal. Since the metal is not pure, it solidifies over a temperature range where multiple states exists, i.e., there is a mixture of both solid and liquids, known as the mushy state. The bubble can leave a "hole" that is either spherical or elongated in the mushy multiphase region.
Often the porosity is located in the last region to solidify, i.e. the centerline of the weld, resulting in aligned porosity along or near the centerline of the weld.
The porosity incubates at the interface between the liquid weld pool and the trailing edge of the weld pool where the temperature drops suddenly to near the solidification temperature. At the interface the weld is in the mushy state where some of the higher temperature constituents have solidified and the lower melting temperature constituents are still in the liquid state. The solubility of the gas drops and it comes out of solution, and makes it way to the surface of the weld.
The porosity that is subsurface is gas doesn’t escape into the air and is frozen in metal. It may be detected by a volumetric examination if it is large enough. However, if the subsurface porosity is small enough, it may escape detection.
Essentially, a gas pore and porosity is one and the same thing. A gas pore is a single "bubble" of gas where as porosity is usually more than one gas "bubble" in the weld.