For the p subshell, the azimuthal quantum number, which describes the angular momentum and shape of the orbitals, is $l=1$. For the associated magnetic quantum number, discrete values in the range $-l, -l+1, ... 0 ..., l-1, l$ are allowed, so the number of different $m_l$ values is $2l+1$.
With $l=1$, it follows that there are $2 \cdot 1+1=3$ p orbitals with the $m_l$ values of -1, 0 and +1, respectively. Each orbital can hold 2 electrons, so the p subshell can contain a maximum of 6 electrons. This also explains why there are 6 elements in the p block of each period. With increasing atomic number $Z$, one p electron is added per element in this block.