Have you finished the forsworn Conspirocy? if so its a bugged quest that causes the guards to go into a glicthed loop if you get caught commiting a crime in the city. there is a fix. Go to the Temple of Talos there will be 3 guards inside, 2 will attack you and one will talk to you do not attack any of them. Engage in the conversation with the one who talks to you. Tell him he is Corrupt follow the dialog, talk to him again it will give you the option to pay off you fine as long as you have to gold in you inventory to do so.
Edit:
Here is the exact fix for both the PC and Xbox/PS3
Helping Madanach escape may trigger all the guards to constantly chase the Dragonborn wanting to arrest them, even long after the quest (it can also occur if the Dragonborn commits a crime in Markarth and reaches a high bounty). There is a solution to this by opening your console and setting all 3 factions that rule Markarth back to 0 fine. Codes being, player.setcrimegold 0 00018aac, player.setcrimegold 0 0008e764, player.setcrimegold 0 0002816c. this also affects Xbox 360 and PS3. To fix on Xbox and PS3, make sure your level is high enough and enter Markarth. Upon entering the city, do not have any guards spot you, and enter the Shrine of Talos. The three guards from the previous quest "The Forsworn Conspiracy," will still be there, and the middle guard will engage in the same conversation as at the end of that quest. The other two guards will attack you, and because you are in conversation, there is no way to fight back, so be prepared. Answer the guard with "You're corrupt, Thonar is paying you," and then again with "Fine, I'll come quietly." The guard will then do nothing, so heal yourself. After a few seconds, the same guard will attempt to arrest you, and give you the option to pay off your bounty.