Since the game doesn't work offline, no command will be answered if the connection is unstable. While playing with a mobile device, even with a good Wi-Fi connection, you’ve got walls, obstructions and other household interference to consider. 

Things that will consume bandwidth and produce interfere with your connection include any downloads you have going on (such as app updates), and also the activity of other people in the house.
Also, power saving mode, low RAM memory, and an outdated operating system and/or router can decrease game's performance in certain cases.

We are constantly working to check our servers and create better game experiences in every update. However, there is still a long list of things that can affect your gameplay.

And how can I fix or prevent this?

Here are some steps that may help you reduce lag in your device:

1. Your GSM or WiFi signal is poor:
Find a place where you get a stronger GSM or WiFi signal. Free or open WiFi networks usually provide low bandwidth and are not ideal for playing. Turn off your phone regularly (every 5 days) to fix IP and DNS problems.
 
2. There is not enough available memory space:
Some devices suffer from a low-memory issue and most perform poorly once they hit around 80% of their storage capacity. You can try to back up ALL your data and make a factory reset, or just delete everything you don’t need, like apps, files, images and videos.
  
3. The game installation is corrupted:
Uninstall the app (make sure your account is saved with Facebook, Game Center, or Google Play first), and install it again.
 
4. The game server suffers from high latency:
Latency is the time it takes for information that your device sends to travel from your mobile to a central server and back to your mobile. Information travels across the internet at the speed of light, but even that is not instantaneous.
Time is still needed for your command to reach the servers, just as it takes time for the server to respond.
We are constantly working to check our servers and create better game experiences. However, specially after updates, many players may login at the same time, causing high latency.
 
5. Your device’s CPU usage is high:
Having resource-hungry apps running in the background can really cause a huge drop in battery life and performance. Live widget feeds, background syncs and push notifications can cause noticeable lag. Regularly close apps and services running in background to release some RAM for your game performance.

Hope this helps!