I have Sidon below my continent and they wanted investors so I have gave them 250 gold and won them over to make then my ally. Then the next turn I get the message Aztec Coup in Sidon so I spent 500 gold and won them back and then the same thing happened then next turn and then the next.
So it happened to me 3 times in a row. How is this possible? I'm playing on King btw.
You've fallen directly into the same trap the AI does in my games.
It's a bad idea in general to give less than 1000 gold, (much more efficient at 1000 even for that quest*), but the #1 rule is never invest a penny in a city state the AI just couped until you get your own spy present, preferably the highest level one you've got.
* The ONLY city state quest in which 250 gold is more efficient is the city state recovering from empty treasury due to being bullied, them having a project is a 50% boost and so benefits the most from the full 1000.
The odds of success are RATIO based. So the higher you get their base value, the higher their odds of success was from sending the same flat amount of gold.
For your first one (at 250 gold), his odds of success were 85% even if he only had a level 1 spy.
If you hadn't sent that but had initially waited until 500 gold, his odds would be less than 85% if he had a mere level 1 spy, but probably still more than 50%.
As is, you'd probably bumped his odds to more than 60% for your first 500 gold and even higher on the next few.
(His odds would be even better at level 2 or 3)
If you'd waited until you had 1000 gold all at once during the investment quest, then if he had a mere level 1 spy, he'd have had really bad odds trying to coup (unless he had sufficient tourism over your culture for the effective spy promotion for coups)
However a level 3 spy still has more than 50% odds of success at a mere 1000 gold even before you increased his value.
Instead either write off the city state or send your best spy in and when the odds become high enough in your favor coup it back yourself.
There's no cool down for coup attempts at all once the spy is established. You can coup every single turn if someone throws the minimum gold to become an ally each turn. Even if you lose a spy, you only have travel time + time to reestablish. (Note that sufficient tourism will greatly decrease time needed to reestablish)