Sep 3, 2015
Yahoo requires new accounts to be set up with a telephone number for validation, and the phone can be any kind. This is so in the future, when someone tries to log in an account, the Yahoo website can ask the person to choose between getting a code, by text or by voice, sent to the telephone number that is in the account records. Without the code, the attempt to log in will be denied. This is called 2-factor authentication; first factor is the name and password, second factor is the challenge by the website with the telephone text/call.
You got the text because ... three possibilities :
1) A scammer typed a random telephone number when they created a Yahoo account, hoping the company would not call the number for verification.
2) A normal person typed their number when they created a Yahoo account ... or thought they did, and got digits mistyped. Now they cannot access that account because they cannot get the code to put in.
3) A hacker got into an existing Yahoo account and and changed the number to your number, intentionally or by mistake.