You should first understand that your mind is just the output of the programming from your past, your ancestors, and your body. Humans are a kind of lifeless robot, just playing out according to the programming in our mind.
Both conditions of being alone and being around people are what you experienced in the past, and they were “added” to your consciousness, programming your mind to a way of thinking and feeling in the world.
This is how our minds are. We’ve made our own little mind world that we are living inside of.
Therefore, somewhere in your life there was some kind of negative response to being alone. According to scientists, the ages of 1–7 years are the most impressionable. When you are alone, there is something in your life which doesn’t match what you want in your mind – in this instance, it’s connected to not wanting to be alone.
Similarly, somewhere in your life there was some kind of positive response to being around people.
In my experience with depression, the best you thing you can do for yourself if you want to be free, is to reflect on the life you have lived, and then let it go from your mind with discarding meditation.
The reason why we let go of the contrasting feelings is that they form of the framework of the mind. If you only let go of the bad, your mind is always going to be subconsciously searching for the good, and so anything that doesn’t match the good is going to be “bad”.