A person can be much more negative towards themselves than anyone else could. The human mind is built to try to solve problems, to notice when things are not right, and to remember negative outcomes. Critical thinking can keep us safe. But unfortunately this can lead to talking to oneself in a harsh way.
Understanding this is the first step toward being nicer to oneself. Most self-criticism is overblown or unnecessary, For instance, if you parents said you were not good at math, this idea will bob up in your mind every time math comes into your life. Even if you are actually adequate in math, you would still habitually believe otherwise. Or perhaps a love affair did not go as you wish. The pain could easily lead you to think you were the main problem when you were not.
Learning to replace negative thoughts with positive ones is a process that can start immediately, but usually happens over time. This is ok - trying to change overnight can be overwhelming. Practicing letting go of one's negativity with rational, positive thinking will eventually win the day.