If you're seeing the ads on the lockscreen, your home screen or when you make calls, usually those ads come from an app that's been installed on the phone.
Popup ads can come from messaging apps, launchers, battery boosters, memory cleaners, flashlight apps, battery apps, calculator apps, and even apps that claim to get rid of viruses. Start with those. You can also check the reviews of the apps you've installed to see if users are complaining about ads.
If you can't identify the app causing the ads, you'll need to remove all the apps that weren't installed on the phone when you got it. Make a list of the apps that you remove so that you can add them back on. After you install an app, try the phone for a while to see if the ads are gone. If they are, then you know you've found it.