I wrote a giant discussion post a while back about how GTA:O suffers from a very shoddy anti-cheat system, but I can't find that post.
Either way, the overarching issue is that Grand Theft Auto Online's anti-cheat protection is not perfect, and often flags behaviour it considers to be "suspicious", even if it is legitimate gameplay (anti-cheats are only ever as good as the rules by which they detect against). It's made worse by the fact that the game is running off an odd P2P model, and a lot of the game's variables are stored and controlled locally without any server verification, and so can be safely edited without Rockstar noticing any issues.
If your internet connection dips, lord help you; it seems like the anti-cheat isn't built to handle people with lower connections polling a lot less, as it thinks you're doing things faster than you really are.
Personally, I wasn't banned at all for the short stretch of time that I modified the Cash/RP modifiers for various types of mission completions (the reward you get at the end of missions/heists/competitive matches/races/etc are determined by multiplying a base value by a number of different multipliers), but a couple months later I was given a week-long ban for playing in the same heist setup as a modder. My money and rank weren't stripped and I kept all my other stuff.