Arrested for breaking the law, I know it sounds weird, but we have a law made long time ago even before Erdogan came to power, you aren't allowed to shit talk the president, if you do you can get a ticket, or get jailed. This law count for the earlier goverments/leader like Ataturk, if you shit talk him you will even if he isn't alive, you can risk to get jailed for 2 years.
Arrested his opponet? Yeah true, he arrested the HDP leader Demirtas for being together with the PKK terrorists(they are in global terrorlist), there is lots of evidence that he has been supporting them. So he deserves to be jailed for being a terrorist.