Why does the iPhone 4S treat a generic 30 pin cable as a line out source?
That's a third-party cable, not an official Apple cable, so what's probably happening is that for some reason that cable is bridging the 2nd and 11th pins, telling the device to send the audio out the 3rd and 4th pins:
From http://pinouts.ru/PortableDevices/ipod_pinout.shtml:


2  GND     Audio &amp; Video ground (-), internally connected with Pin 1 on iPod motherboard
3  Right   Line Out - R (+) (Audio output, right channel)
4  Left    Line Out - L(+) (Audio output, left channel)
11     AUDIO_SW    If connected to GND the iPhone sends audio signals through pin 3-4, otherwise it uses onboard speaker.