Yep. Sounds like you picked up a bounty of some sort in that town. :yes: Either that or you're a full blown vampire, got caught feasting on someone as a vampire, tried to stroll into town in full werewolf form, or someone in the town previously witnessed your transformation into a werewolf....
Check your cirme stats in the General menu to see what your crime rating is in that particular hold.
Either way, you're going to have to pay the bounty fine to clear your record. Keep in mind that the fines and ultimate penalties (jailtime and skill degradation) will be less severe If you're skilled in the art of persuation (eg bribing the guards) or a member of the Thieves Guild.
edit: I just reread what you posted here:
I was so impatient to see Markarth, it was so beautiful in the trailers... and as I was approaching, a "Markarth guard" attacked me on sight!
have you already sided with a faction in the civil war? If so, was it with the Stormcloaks? It suddenly occured to me that this might be the case. If so, then imperial faction which owns the city would naturally take offense to your person