To answer your question, as others have already mentioned, the practice is in order to increase safety, by not allowing a malicious user or script to know whether a given username is taken (available to try to "hack into"). It is not a legal issue, since, as you noted, not all services do this.
Interestingly, though, in practice this is not all that safer given other design decisions (for an email account, all you have to do is send an email and if it doesn't bounce, you have a pretty good idea whether it is available). Your question reminded me of a great article I read about this a while ago:
Social Login Buttons Aren’t Worth It
Here are the relevant parts:
While researching login patterns in the wild, we also watched some users on our login page, and pinpointed a few smallish things we could change to make getting into the app easier. Our old login form told users, "Your username or password is incorrect," when they may have the username right, but the password was incorrect. If you have 4 possible usernames and 4 possible passwords, you have 16 possible combinations between them—only one of which is correct. That means in this scenario, the user would have 15 chances to make an error when logging in. But when you know specifically that your username is incorrect, odds of failure drop precipitously.
He is referring to the fact that some UX changes in the login screen (for their app) caused a 66% decrease in login failures and a 42% decrease in password resets with an additional 5% decrease the following month.
While researching login patterns in the wild, we also watched some users on our login page, and pinpointed a few smallish things we could change to make getting into the app easier. Our old login form told users, "Your username or password is incorrect," when they may have the username right, but the password was incorrect. If you have 4 possible usernames and 4 possible passwords, you have 16 possible combinations between them—only one of which is correct. That means in this scenario, the user would have 15 chances to make an error when logging in. But when you know specifically that your username is incorrect, odds of failure drop precipitously.
The engineering team, ever mindful of security, argued that being generic about username and password errors makes it harder for bad guys to guess usernames by pounding the form with random words or email addresses. But after some further consideration, we decided that it was a false risk, as the username reminder form already tells you if a username exists, and is not a significant security risk for the bajilions of sites that have them.
So, though it might seem that not informing the user trying to login that "the username exists but the password is wrong" is a security feature, this can be undermined by other decisions, and in reality is fraught with another set of problems itself (bad logins, password resets.. etc). So each case needs to consider all of this in order to make the best decision.