first off your phone is not hacked. people use that term way too much. what you have is something called adware. it is a form of malware.
here read this:
https://www.malwarebytes.com/adware
usually adware gets installed when you download an app. even though it comes from the play store does not necessarily mean it is clean and safe. you need to read the permissions and see what the app you want has access to on your phone. for instance if a wallpaper app wants access to your phone or contacts, that would seem odd and i would never install something like that.
to confirm that this is adware you can put the phone in safe mode.
https://www.hardreset.info/devices/motorola/motorola-one-power/safe-mode/
this will determine if what is happening is from 3rd party apps or not. if you do not see any ads then it is coming from an app you installed recently. now you need to get out of safe mode and look at what apps you recently installed. start with the most recent and work your way down.
here are the steps:
1.identify the app
2.wipe cache and data for the app. this is found in your phone settings under apps.
3.uninstall the app
5.reboot your phone.
if that one does not work than you need to continue down the list of most recent apps installed. if you do not know how to find this, you can go into the play store and look into the "my apps" setting. you can then look for installed or purchased list.
a factory reset will work, but only until the app in question gets re-installed by you.....so it is important to identify what app it is and not have it installed on your phone.
good luck and keep us posted.