Where did I lose control of my studies? I am a 5th MSc semester mathematics student at a local German university. Since fall, I have been working on my thesis, which is the only remaining task for finishing my studies.

I had not had particular difficulties during my studies, apart from the usual struggling and doubts I suppose every student undergoes: before my masters studies, I had spent 7 semesters at another university on two BScs in physics and mathematics. I am paid by a public scholarship. I had decided to change the university for my master's half for personal reasons and half in order to have a greater choice in courses held. My average score is 1.5 at the moment, which also had been my final score for the two BScs.

Now that I have started my thesis, nearly everything has changed: I am working with a professor whose courses I took several of, all with good grades, so she did not object to supervising my thesis. Although I have not had severe problems with my studies before, I am getting nowhere with my work now:

For understanding a single paper I am supposed to work on I sometimes need weeks, let alone the questions posed to me to think on, which I sometimes spend weeks without any serious results I could present. I have the impression that I am lacking creativity, intuition and a sufficient knowledge which I think I should have acquainted during my courses.

My problems have driven me into particular personal problems: I have lost contact with most of my former colleagues I used to spend every weekend with, partially because they seem to have lost interest in spending time with me, and partially because my mind is governed by thinking of my inferior scientific performance and the conviction no one wants to have to do with such a poor student. I cannot enjoy leisure time since I permanently have to think of the open problems that haven't worked out over a long time. I cannot claim to have chosen a university where I am competing with the best.

For 1½ months I have been taking antidepressives and having psychotherapy, which barely helps to soften the biggest peaks of auto-aggression and contemplating self-harm, but have not yet helped me to find another view on what I'm doing.

TL;DR

Although my university performance seemed sufficient for me not to worry much about it, starting working on my master's thesis has revealed a vast lack of mathematical knowledge and poor mathematical working capabilities. The longer I work on it, the more I lose any self-esteem. 

Question: Where should I have foreseen my problems? Which signs did I ignore? Where did I miss to put things on the right track? And: how shall I find value in myself, now that I have found myself incapable of pursuing research, and have lost everything else?
Nothing you've described sounds like a serious academic problem.  Taking weeks to understand a paper, and working on a problem for weeks without results, are entirely normal in research mathematics.  And there is always a large gap between what you learn in coursework and what you need for research.  

Trying to get better by just working harder or longer can be counterproductive.  It is important to spend time on other things, even when you feel like you're way behind.

Clearly you have some problems with mental health right now.  I'm not qualified to advise you on that, but it's good that you're getting professional help, and it's only been 1.5 months - such issues don't usually get "cured" as quickly as that.  Even if it takes time to get better and delays your academic progress, that's not a major problem.  Academia works on very long timescales and several months of low productivity is nothing in the big picture.

At the end of the day, maybe you'll decide you just don't like doing mathematics research.  That's okay too, there are lots of other things you can do with your life.  Math is particularly difficult in this regard, in that math coursework has a very different flavor from doing research (exercises with short elegant solutions, versus long messy problems with awkward solutions that only accomplish half of what you really want).  Liking coursework is not necessarily a good indication of the same for research, so a lot of people do leave the field at this stage.  Again, there is nothing wrong with that.

Professional mathematicians tend to be people who really do enjoy doing mathematics research, and they tend to describe the work in terms that make it sound like it is inherently enjoyable and anyone that doesn't like it must be broken somehow.  But that's not true.  If you get better and discover that you enjoy it, great.  If not, that's great too.