According to this, when you connect to a hidden service using tor you
go through 6 nodes instead of 3... why?
To hide the hidden service IP address in case the rendezvous point is under adversary control.
The hidden service communicates with Tor client through a chosen node, which is called rendezvous point (RP). Normally they both build a standard Tor circuit of three hops to this node. If RP is controlled by an adversary, and hidden service communicates to RP directly, without intermediate TOR nodes, this communication would reveal its IP address to RP. Communicating through other Tor nodes helps protecting it.
A new Tor version has a setting which allows the hidden services, which do not need or don't care to hide their IP address, to communicate to RP directly.
I suggest this article, which explains how hidden services work.
From what I understand when you connect to a website that is not a
hidden service you connect to their IP, but it is shown as a domain
name, but you can ping and find out there IP, can this be done with a
hidden service on the tor network? Please explain why or why not.
The answer is no, it cannot be done for Tor hidden service, because the system works very differently. Notably Tor does not use nor needs DNS for resolving domain names; Tor "hidden service" name is essentially a fingerprint of the hidden service private key (80 bits of its private key hash, encoded via BASE32 to be specific). Thus it is not possible to resolve it to an IP address, and therefore to ping it.
Note that hidden services might be deployed without IP address at all; while a machine running Tor would have an IP address, the hidden service itself might only listen on HiddenServicePort and thus be not available without Tor at all.
If not, then their IP is hidden, so how is it possible to connect to
Tor network uses different mechanisms, as stated in the article mentioned above.
On torproject.org it is explained that there are 3 layers of
encryption when connecting to clearnet, and when each is decrypted, it
only shows the address of the next node, everyhting else is encrypted,
except on the exit node, as long as you are not using SSL/TLS... Does
this work the same way with a hidden service just with 6 hops instead
Yes. This is different case from communicating with a server on Internet. Because your Tor node can verify the authenticity of the hidden service private key (by using the hash from its .onion name), it is possible to securely encrypt the information end-to-end. Notably the rendezvous point does NOT see any content passing from or to the hidden service.
I also know that no exit node is used when connecting to a hidden
service on tor, and is therefore end to end encrypted. Why is there no
Because the traffic does not exit Tor network (i.e. into regular Internet), thus there is no need for an exit node.
And how is it end to end encrypted? How does the hidden service hoster
As far as I know (but not 100% sure), the end-to-end encryption after rendezvous is the same as with Tor circuit (i.e. Tor talking to the exit node).
See above regarding anonymous.