Activation codes are time-sensitive. If you do not enter them within a certain period, they get expired and thus appear invalid. In such a case, generate a new code from your TV screen and use it on youtube.com/activate to link your device.