It's most likely a combination of both, but mainly the game. The Samsung A12 isn't the most powerful phone, so when the game tries to load all your inventory data at once, the RAM gets a bit overloaded and that's why you freeze for those 5 seconds. Then it recovers because it manages to process it. That's pretty common in heavier games running on more modest devices.
First, try these things: open your phone's settings, go to Applications and search for the game, tap "Storage" and select "Clear cache" (it won't delete your progress, just the temporary data). Then restart your phone. If you keep having the problem, try reducing the graphics quality inside the game itself, turn off real-time synchronization if the game has it enabled, and close all apps you're not using before you play.
If it keeps freezing after that, it's most likely an issue with the game itself, not your phone. In that case you can leave a review on the Play Store mentioning the problem, because that's information that helps developers know there's a bug. In the meantime, if the game has a lite or lighter version, try that alternative.