You can easily prevent accidental or unauthorised purchases by enabling purchase authentication on the device you use.
How to do it on iOS?
Start by opening the Settings app and navigate to General > Restrictions. Tap on Enable Restrictions and create a Restrictions passcode in case you have not yet done so. You can then either turn off the In-App Purchases to prevent all in-app purchases, or alternatively tap Password Settings and choose the desired setting under Purchases and In-App Purchases to require a password before purchases can be made.
Password settings can also be changed from Settings > [your name] > iTunes & App Store, or from Settings > iTunes & App Store in case you are running iOS 10.2 or an earlier iOS version on your device.
How to do it on Android?
Firstly open Google Play Store app and tap the Menu icon > Settings, then tap Require authentication for purchases. Choose the desired setting and follow the instructions on the screen.
Please note that the purchase authentication applies only to the device on which you enable it so in case you have multiple Android devices, the purchase authentication has to be enabled separately on all of them.