Make sure you are using the correct code.
To make sure its the correct code login to your email account, delete all emails with the codes, check that they are all deleted then fully close Steam or even restart your computer and only try to login ONCE and use the one and only code you got in your email.

If it still wont work you have to contact Steam Support for more assistance.