This is one of the hardest things about mental health.
When I was poor and on my way to homelessness and saw no way out, I felt horrible. Years later, when I was rich and rising successfully in my career and was by all measures a pretty successful person, I...felt horrible. And I felt horrible in exactly the same way! The voice in my head said the same things, in the same language.
The thing about self-loathing and about anxiety is that it isn't the result of your circumstances, but it does justify itself by using your circumstances. So when I was poor, I hated myself "because" I couldn't afford groceries. And when I was doing well in my career, I hated myself "because" I fucked up at work. But more properly, I just hated myself, and was looking for justifications as to why that was. 
I was like a detective who has been told a murder occurred, looking for any data in the environment as to why the murder occurred. "Oh, I see, a broken twig, that must be where the murderer came from!" "Aha, a hammer, that must be the murder weapon!" And all of that made sense...except that no murder had actually occurred in the first place. I was fitting that data into the existing narrative, rather than questioning the narrative itself.

Now, that's not to say environment doesn't matter, just that it isn't one-to-one with how you feel. Yes, a better environment will probably help, and yes, your current environment might be hurting. But there are plenty of people in worse environments than you who are happy, and plenty of people in better environments than you who are miserable. That isn't to say "oh, just think positive", which (in that form) is not very good advice. It's to say that circumstances and how you feel are different things.
One of the best analogies I have for mental health is color. You remember that dress that set the internet on fire five or ten years ago? Where half the internet was absolutely convinced it was white and gold and the other half was absolutely convinced it was blue and black? Everyone was looking at the same image, but taking something totally different from it.
That's because color, like all perceptions, isn't a property of the world. It's a property of your mind. It is of course related to the world, but it's filtered through many layers of unconscious processing long before it gets to any direct awareness by you as a conscious being - layers that can tell you the dress is white and gold or that it's black and blue in a way that, unless you are really vigilant or can compare to the experiences of others, you'll never notice.
The same is going on right now. Your brain wants to interpret your world as black and blue, and it is serving up the world to your conscious mind in a form that is so obviously black and blue that you as a conscious being are going "well, duh, how could it be otherwise?". And your therapist is telling you well, actually that dress is white and gold, and you are going "um no that's fucking stupid it is obviously black".
What your therapist is trying to do here isn't to tell you you're being irrational. It's to tell you that your subconscious processing systems are broken in a way that is distorting the version of reality that can get into your brain. Those processing systems are looking for ways to interpret the world as proof that you're a bad person. And since most people are flawed, it isn't hard for them to find it.

So, to get back to your questions:

Honestly, I don't understand this, isn't this how it works? Don't we all tend to tie our self worth to our accomplishments etc or am just an idiot out there?

We do to some extent. And in particular, healthy people can do this, because their brain doesn't minimize their accomplishments and magnify their faults. When they look at a dress, they see its color as it is, more or less, and so they don't think the world has more of one color than another.
But even then, things are comparative, not absolute. A student at Harvard who gets worse grades than other Harvard students might feel bad about that, even though they are, objectively, still far smarter than the average person. Someone who wins Employee of the Month at their local McDonalds franchise might feel good, even though that's not a very high bar. (This is part of why self-esteem can be harder in the modern world: we are exposed much more to people more successful than ourselves, and much less to people who are less successful.)
Suppose you knew someone who had a severe disability. They can barely walk, or they're significantly less intelligent than the average person. Are they necessarily miserable, even though they objectively have much lower capability than others? Would you say they should dislike themselves for accomplishing less?

How are they gonna accept and love themselves because there's something wrong with the person which got them in such a position in the first place.

This is a very important point.
There is a difference between "I am sad" and "I deserve to be sad".
Right now, your miserable circumstances are more than just miserable circumstances. They are a cudgel with which you can beat yourself. They act as "proof" of your self-loathing, as concrete demonstrations of your "failures", because you're seeing those circumstances through the broken processing layers we were talking about a little while ago.
Part of the reason depression and anxiety are "sticky" is that they run on this loop. You feel bad, so you feel like you deserve to feel bad, so you beat yourself up more, so you sink further into depression, so you feel worse. And so on.
There is "something wrong with you" only in the sense that there is something wrong with someone who has a broken leg. It makes it harder for you to do certain things. But it isn't a moral failing on your part. You are sick, not bad. We don't call it "mental illness" for nothing: it is no more a failing of you as a person than getting the flu is.
When you get the flu, you might feel bad. You might roll around feeling miserable. Your head pounds, you throw up every couple hours, and it's just an awful time. But at no point while having the flu did you do anything wrong. You just felt bad. And you'd understand that your suffering is just a temporary thing that isn't under your direct control. Sure, you can do a few things to help it pass (drink plenty of water, get some sleep). But you can't choose not to have the flu. You don't hate yourself for having it. You don't feel like having the flu is some immutable part of what you are.
When your therapist says to love yourself, they don't mean "stop working on your problems". They mean "stop treating your problems as a way in which you, as a person, are bad, and start treating them as external problems to be solved".

Idk maybe I never felt loved and accepted

Yeah, me either. I still struggle with that bit. I still constantly feel not good enough. But I have learned not to listen to that feeling too much. And I've learned to remind myself that when I falter, I didn't falter because I'm a bad person, I faltered because life is hard and because I'm burdened with a difficult path in life. 
If I don't accomplish what I want to today, I'll feel sad, but I'll go "man, that sucked", curl up with a comforting book, cry a little, and go to sleep. And then I'll try again tomorrow. I can't not be depressed or anxious sometimes, because that's just how my brain works. But I can learn to cope with them and to navigate around them in ways that prevent them from establishing the debilitating loops in which I spent most of my life.