Thanks for asking the question first. I always like to share what I have learned to others.
Let me just cover the basics of how a bitcoin address is generated first. Initially a private key is generated by a bitcoin wallet and the number of private keys present is unfathomably large (i.e over 2256). G is a point on Elliptic Curve and when any value in the order of 1 to G is multiplied with the private key it yields another point on the elliptic curve. This derived point is called as Public Key. Note that this is a one way multiplication and dividing public key by the generator point would never yield you the private key.
Privkey * G = Pubkey
where,
Privkey = Private Key
G = Any point on curve
Pubkey = Public Key
When you hash the public key with SHA256 and further with RIPEMD160 you would get a string of characters. These characters are certainly large and a Base58 check encoding is done. This would yield you the address starting with 1.
Address starting with 1 = Base58check(RIPEMD160[SHA256[PubKey]])
Now coming to the addresses and transaction types
1. P2PKH [Pay to Public Key Hash] :
This is the general legacy address transaction and this is how most of the general transactions occur in Bitcoin Network. Consider Madhav Singh is paying Heisenberg 0.001BTC Here the transacted bitcoin is locked in a script which isn't spendable without the Heisenberg's signature and Public Key. When it matches the bitcoins are unlocked and can be spent by Heisenberg.
2. P2SH addresses [Pay to Script Hash] :
We do know that, when Base58 check is added to the public key it yields a bitcoin address starting at 1. Here Base58 check encoding is done to the script hash instead of a Public Key. Please read BIP-13 for more info on this type of address starting with 3.
Please note that addresses which start with 3 necessarily doesn't want to be SEGWIT all times. They may or may not be SEGWIT. But addresses which start with bc1 are definitely SEGWIT addresses. Please read the old post of mine to know more about Multi-signatures
A little insight on SEGWIT as well
Older bitcoin transactions were measured based on the size of the transaction such that a bitcoin block can consist of only 1 MB transactions. With the introduction of segwit, the transaction size was never considered rather Weight Units were taken into consideration. A bitcoin block can have 4 million weight units which is equivalent to 1 million virtual bytes.
Must have a read on BIP 141 for better insight on what a SEGWIT actually is.
Hope this post gives you an insight on what different bitcoin addresses are.