I don't want to update my iPhone 3GS from iOS 5 to iOS 6. I think this happens automatically via WiFi update. How do I stop it from downloading and installing itself?
Fortunately for you, iOS will not update without your consent. You have to physically go in and choose to Download, and Install the Update (two steps) in order for it to update to the next version of iOS.
iOS 5 or higher have a feature called OTA (Over the Air) updates, which bring the convenience of not having to plug your iPhone into iTunes to update it - which you are aware of. It displays a badge on the Settings app on iPhone homescreen, but this will still not update without your consent (unlike some Windows OS updates).
Unfortunately, the Settings.app is not in the list of notifications that you have control. So you will have to get used to seeing the "1" on the Settings.app.
You will also have to be careful to decline (skip) updating your device anytime you plug it in via USB to iTunes. One thing to note, is that you don't have to worry about Wifi syncing with your device. It will not update your device using iTunes Wifi sync.
To prevent an update, don't start the download and/or don't install it once it downloads.
Also, don't download the update using iTunes or let it get downloaded / applied when you connect or restore the device in iTunes. This is also covered in the article above. If you (or someone else) may have clicked "don't remind me again" in iTunes about another iOS update, to be thorough, reset all warnings in iTunes to ensure you see that warning if/when it pops up for iOS 6 and future updates.