How do we know the number of s and p orbitals in a shell?
The number of orbitals in a shell is restricted by the possible values for the quantum numbers. Those come directly from the solution of the Schrödinger Equation for the Hydrogen atom (except for the spin, but let's keep it simple here), and are applied to all other atoms as well.

The quantum numbers and their possible values are:


the principal quantum number $n=1,2,3,4,5 \dots$, which relates to the period
the angular momentum quantum number $l=0,1,\dots, (n-1)$ which defines the shape of the orbitals $s$, $p$, $d$ and so on
the magnetic quantum number $m_l=-l,-l+1,\dots,+l$ further define the shape, e.g. $p_x$ or $d_{z^2}$
the total spin for electrons is always $s=\frac{1}{2}$ (this may be different for other elementary particles)
the relative spin of an electron is $m_s=-\frac{1}{2},+\frac{1}{2}$, and represents $\alpha$ and $\beta$ or up and down spin


Each electron needs to have its own unique set of quantum numbers (within one atom). This is know as Pauli Principle.

Thus for $s$ orbitals ($l=0$) there is only $m_l=0$ possible, hence there can only be one for each shell ($n$). Having four $2s$ orbitals would violate the Pauli Principle.
Additionally having a $2d$ orbital would also not be allowed as $l=2$ would be larger than $(n-1)=1$. So the $n=2$ shell is restricted to one $2s$ orbital ($m_l=0$) and three $2p$ orbitals ($m_l=-1,0,+1$).