Hitting the restore button in iTunes will update you to the latest version. Shift+Restoring will let you choose what FW version you want by letting you browse to the ipsw file saved on your desktop. I'm assuming you restored instead of shift+restored and that's why it updated to 3.1. It's ok though, there's a fix.
3.1 is jailbreakable (only on a Mac) but you have to use a prehacked version of 3.1 in Pwnage Tool to preserve the baseband if you are going to unlock. There is no unlock currently available for the the updated baseband that comes with 3.1 when updated in iTunes.
However, if you accidentally updated to 3.1, you can revert back to an older firmware by restoring again, but it retains the updated baseband. So after restoring, you have to downgrade it.
Here's a video for downgrading the baseband. Shift+Restore to 3.0.1 first, that is unless you have access to a Mac for jailbreaking on 3.1.