If you have set up 2-step verification for your Apple ID then the first time you use it to sign into iCloud on a new device, or to www.icloud.com on a new device, you will be asked to input a 4 digit code which is sent to the mobile device you nominated when this was set up, and it is on that mobile device only that you will receive a text message giving you a four digit code.
Setting up 2-step verification is a procedure that you would hardly be likely to forget you had done, but you haven't confirmed whether or not you did this. If you did do it and can't receive a code, then you were given an emergency code which you were supposed to write down and keep in a safe place and which you can use instead (using the link for this in the request).
If you didn't ever set up 2-step verification than I don't know what is causing this. Your best bet is probably to treat it as a security problem and contact Support. This Apple Help page provides contact information for various countries for security problems with an Apple ID:
http://support.apple.com/en-us/HT5699