What are the maximum number of electrons in each shell?
Shells and orbitals are not the same. In terms of quantum numbers, electrons in different shells will have different values of principal quantum number n.

To answer your question...

In the first shell (n=1), we have:


The 1s orbital


In the second shell (n=2), we have:


The 2s orbital
The 2p orbitals


In the third shell (n=3), we have:


The 3s orbital
The 3p orbitals
The 3d orbitals


In the fourth shell (n=4), we have:


The 4s orbital
The 4p orbitals
The 4d orbitals
The 4f orbitals


So another kind of orbitals (s, p, d, f) becomes available as we go to a shell with higher n. The number in front of the letter signifies which shell the orbital(s) are in. So the 7s orbital will be in the 7th shell.

Now for the different kinds of orbitals
Each kind of orbital has a different "shape", as you can see on the picture below. You can also see that:


The s-kind has only one orbital
The p-kind has three orbitals
The d-kind has five orbitals
The f-kind has seven orbitals




Each orbital can hold two electrons. One spin-up and one spin-down. This means that the 1s, 2s, 3s, 4s, etc., can each hold two electrons because they each have only one orbital.

The 2p, 3p, 4p, etc., can each hold six electrons because they each have three orbitals, that can hold two electrons each (3*2=6).

The 3d, 4d etc., can each hold ten electrons, because they each have five orbitals, and each orbital can hold two electrons (5*2=10).

Thus, to find the number of electrons possible per shell

First, we look at the n=1 shell (the first shell). It has:


The 1s orbital


An s-orbital holds 2 electrons. Thus n=1 shell can hold two electrons.

The n=2 (second) shell has:


The 2s orbital
The 2p orbitals


s-orbitals can hold 2 electrons, the p-orbitals can hold 6 electrons. Thus, the second shell can have 8 electrons.

The n=3 (third) shell has:


The 3s orbital
The 3p orbitals
The 3d orbitals


s-orbitals can hold 2 electrons, p-orbitals can hold 6, and d-orbitals can hold 10, for a total of 18 electrons.

Therefore, the formula $2n^2$ holds! What is the difference between your two methods?

There's an important distinction between "the number of electrons possible in a shell" and "the number of valence electrons possible for a period of elements".

There's space for $18 \text{e}^-$ in the 3rd shell: $3s + 3p + 3d = 2 + 6 + 10 = 18$, however, elements in the 3rd period only have up to 8 valence electrons. This is because the $3d$-orbitals aren't filled until we get to elements from the 4th period - ie. elements from the 3rd period don't fill the 3rd shell.

The orbitals are filled so that the ones of lowest energy are filled first. The energy is roughly like this:

$$1s &lt; 2s &lt; 2p &lt; 3s &lt; 3p &lt; 4s &lt; 3d &lt; 4p &lt; 5s$$

An easy way to visualize this is like this: