Your post is a little unclear. Are you saying you just bought the phone and turned it on for the first time and it was asking for a password? If so, then that phone is used and most likely someone else's Google account is signed in. When it gets factory reset, the phone will ask for the account login info of whoever was last signed in. Since this wasn't you, you will not be able to use the phone and you will need to address this with whoever you bought it from.
If you've been using the phone already and this is a new problem, yes you can use the phone again, but with a caveat. Lock screen passwords don't just pop up out of nowhere, which means someone has tampered with your phone (I'm assuming this because it sounds like you didn't set a lock screen password). Before you set your phone up again, you need to change your Google account password from another device in case a hacker got your current one somehow. While you're at it, it would be a good idea to change all of your passwords.
Once changed, then try to set up your phone again. It will ask you to verify your Google account info, so you'll use the new password you set (it may take a couple days for it to update across the system and let you in to the phone). Once verified, then finish the setup process. Because the phone was factory reset, this does mean you'll be starting from scratch and any data not backed up would be lost.
If you need additional help, feel free to create an account here so you can reply and also clarify what the exact problem is.