So basically, these cables serve the same function, right? They are both used to output data from the source to an amplifier or a receiver or both. The only difference(correct me please if I'm wrong) is that one is analog while the other is digital.
Not quite. Yes, they carry 'data' from the source to the amp or receiver. But don't underplay the analog vs. digital difference.
With the 6 RCA cables, the electric signal travelling along the wires are analogs of the actual sound waveform. Hence, any physical or electrical interference to the electric signal directly affect the sound output. This interference/distortion can be introduced by faulty/substandard terminations, RF interference, ground loop hum, to interconnect cable properties and dielectric skin effect if you believe the exotic cable manufacturers.
With the digital Toslink cable, the signal is a data stream of bits transmitted optically, distinct 0's and 1's, that carry encoded audio. At any point in time the light is either on or off. Any physical interference will either be major (preventing the data from being transmitted AT ALL), or in conceivably very rare cases intermittent, causing 1 bit out of every, say, 1000 to be transmitted incorrectly. But most, if not all digital encoding/trasmission schemes have built-in error correction (or at least error detection) that handles that 1 in a 1000 rare occurence. And if the error becomes to great to correct, then its simply interpreted as a lost signal.
Also, because of the digital encoding, a single optical cable has more than enough bandwidth to carry 5, 6, 7 or more channels of digital audio. A fat wire also has ample bandwidth to carry several signals - but at certain (high) frequencies you start running into RF issues and wire RLC limitations. On the other hand, a good optical cable can carry signals in the MHz frequencies with no problems.
Finally, in your particular case, most of the time dedicated receivers/amps have better decoding circuitry and digital to analog conversion circuitry than most sources/transports. For example, in my case I use an Xbox - yep, a $100 gaming console as my transport. I don't care, because I'm certain that the CD audio signal transmitted optically, digitally to the receiver will arrive there exactly as it was recorded. I then let the receiver do the job of decoding and analog conversion, knowing it'll do the job better than the Xbox ever could.
What I don't get is How can one toslink cable outdo 6 separate, fat and good quality RCA cables just like how one HDMI cable beat 3 excellent component cable for video(but I heard from sources it really does).
Same explanation. Ever ask yourself why (digital) satellite cable TV transmission is (generally) better than analog cable transmission? Or why digital GSM telephones are better than the now extinct analog CDMA phones? Or why undersea long-distance telecom lines use millimeter thin optical fiber rather than copper wires inches thick?