Apart from the fact that the 3GS has completely different internals (including a new processor) than the the 32GB iPod touch, the reason you have to buy out your contract is because when you signed up for the 18 month contract you agreed to pay a minimum 18 months worth of airtime to O2. If you renew early and start a new 18 month contract you are, in effect, reducing the minimum number of monthly payments you agreed to.
For example, if you got a 3G, see out your full contract and get a 3GS you are paying O2 36 months of airtime.
If you renew after 1 year, you are paying 30 months of airtime so O2 lose 6 months of airtime revenue from you which is why you have to pay the whole contract up.
Carriers set prices for everything (i.e. handsets and airtime) based on this contract period - it's not just about paying back the subsidy on the handset, it's about compensating the carrier for revenue they could reasonably expect to receive based on a signed contract.