Malicious code is not an easy thing to do on Android unless you have given it Root access.
More likely it is an app; specifically, another form of "advertising" in which the app keeps directing you to the Play store in hopes that you will purchase an app on which the first app developer will earn a commission (or it is another app by the same developer).
The best way to avoid this scenario is to *always* go through a several pages of user reviews before installing any app. If an app has abusive advertising policies, others will have complained about it.