Praise be to Allah,
Assalamualaikum!
I used to have the same problems as you. Just keep remembering Allah and how he is the most merciful. If you keep doubting yourself and how your doing everything wrong, then think to yourself you are doing your best to please Allah and remind yourself. Another suggestion is that if you keep doubting yourself, then remind yourself that is Shaitans whisper that is full of hatred and ignore it. Think to yourself you are trying to beat Shaitans whisper and you are trying to please Allah the best you can and Shaitans whisper will not be an obstacle for you.If you want to get rid of bad thoughts, then to get your mind off of them, read the Quran, and understand the meanings of it to feel at peace and away from those bad thoughts. Just try your best to please Allah and remind yourself that you love Allah and don't let Shaitans whisper be an obstacle between you and Allah. If you keep feeling sad then read the Quran. Allah's words will bring you at peace and your bad thoughts will be gone soon. InshAllah, I hope this helps and your problem gets better. I'm very sure these will help for you, but make Dua'a as well this problem will get better for you.
Hope this problem gets better for you! InshAllah!