The answer is that P and S boxes are effectively two halves of the same thing. This is the reason people confuse the two.
e-sushi's S-P network diagrame-sushi's S-P network diagram is an excellent example of the reason for needing both. The object of a cryptographic function is to alter the input in an unpredictable way, be it for an encryption cypher or a hash. That means what comes out bears very little resemblance to what went in. This is Shannon's confusion and diffusion principle.
The best theoretical way to mangle the input bits (it's all a question of bit mangling) is to use a look up table to replace the incoming byte with it's stored value, as in $x=S[x]$ with $S$ populated with random numbers. For a byte that's great. $S$ would be $2^8$ values that could be stored as 256 bytes. e-sushi shows an encryption of 64 bits which is a common block size for something like DES (I know it's $2 \times 32$ bits but who's counting?) That would require $2^{64}$ 64 bit words in $S$, in a perfect world. That's actually $2^{64} \times 8$ bytes or about $10^{20}$ bytes. More than enough to fill a few floppy discs. This is one of the reasons that cryptography deals with large numbers.
These things have to run on anything from mainframes to smart cards and iButtons for wide stream acceptance. e-sushi shows us 16 smaller S boxes with $2^4$ bit inputs. That requires $2^4 \times 16$ nibbles or 128 bytes. Amazing! Where did all that storage requirement go?
Problem is that a 4 bit S box isn't that dissimilar to a 1 bit input box, i.e. a direct 1 - 1 mapping. You've sacrificed storage for less bit mangling and so less security and invert-ability. Hence the P box to distribute the S box output as broadly as possible before doing it all again. e-sushi's P box has a 1 - 1 mapping at the bit level, but it doesn't have to. Any bit can map to any other so the input and output widths do not have to match. You can lose bits, and you can duplicate bits.
Putting the S and P boxes together creates another type of function so that now we have $x=f(x)$. You might call this a Feistel function. If you're really good at it you might call it a Bent function as well. Somewhere inside there you might also stuff in some modular arithmetic and /or bitwise operations like SHA-1. And so you go round and round (in what are called rounds surprisingly) till you think that the original input is sufficiently encrypted. You've traded storage space for cpu cycles /time.
So in summary, in order to mangle the bits better and for the algorithm's implementation onto commonly used hardware, you must compromise and perform a balancing act between S and P boxes. You therefore balance security as well.