In layman's terms, TOR works like this.
I need to send a letter to person C. Instead of sending it directly to them and having them reply, I instead send a letter to person A. Person A takes the letter out of the envelope, encrypts what's inside, and then sends that letter in a new envelope to person B. Person B takes the letter out of the envelope, encrypts the data again, and puts it in a final new envelope and sends it to person C. Person C sees the data request, sends the webpage info back to person B, who then sends it to person A, and then back to me.
All of these transactions are encrypted and none of the "exit nodes" (read: websites) know who it is that will ultimately receive the packet of information they send out. This, coupled with the fact that people's IP addresses are changed and relayed every few minutes leads to damn near perfect anonymity on TOR.
Problems arise if poor security somewhere in the chain, i.e. someone doesn't take your letter out of the envelope to send it to the next person in the chain, allows the exit node to discover who the packets are ultimately supposed to be delivered to.
EDIT: This is in stark contrast to the way the traditional web works where every node in the chain (meaning your ISP and all of the datacenters your packets pass through to get to their final destination) pass on both WHO you are and WHAT you're requesting. This is why websites know your IP address.