Well, if you are tagged, other players can attack you. This is due to the fact that many players liked it to "gank" others with blocking paths, etc. so these couldn't leave buildings or other closed environments. In normal, guards / the game should warn you first and taggs you, if you don't move away after the warning.
General rule: Try to not stand in doors when guards are around or if you are in a guarded town.