Let's start taking a look at the kanji of the word: shitsu 失 means "without," and rei 礼 means gratitude. The word shitsugyou 失業 for example, means "unemployed" (without a job) and rei wo iu 礼を言う means "to say thanks."
Well, that didn't help much. Now we know it means literally without rei, which can be interpreted as "without manners," but that does not really explain the two meanings of the word shitsurei, does it?
The answer lies in how flexible the word is when we are talking about behavior. See:
- sore wa shitsurei desho? それは失礼でしょ？
That (which you did) is impolite, isn't it?
(used when someone is about to do or did something impolite)
- shitsurei wo itashimashita 失礼をいたしました
I did [something] impolite. (excuse me)
- kore wa shitsurei これは失礼
This is impolite. (excuse me)
- shitsurei wo oyurushi kudasai 失礼をお許しください
Please forgive the impoliteness. (excuse me)
So, basically, when a character says shitsurei, what they are really doing is either announcing they are aware of the impoliteness they themselves are doing, or blaming someone for being impolite. In the first case, we can interpret it, most of the time, as asking to be excused, though in some rare cases it's like "I am going to be impolite."