Is it good to automatically sign up a user if he doesn’t have an account?

On some sites when you don't have an account, you are asked: "Sign in with Gmail" or "Sign in with Facebook". When you click and your account isn't found, it automatically signs you up using the selected social network, in other places like Stack Exchange for example: when you log in and you don't have an account: it ask you to confirm like below:

enter image description here.

I am working on something and I am wondering which one will be the best practice.