tennnis below the pro level is literally a comedy of errors.
By that I mean that matches are almost always decided by who makes unforced errors and who doesnt. People remember their winners, but as your finding out, the errors decide things.
Here are a couple of things that you might try, they worked for me over the years.
1] hit your first serve with a little more kick. You should get more in and that will get your confidence up.
2] Take the ball a little earlier, or at least try to make sure you are not hitting the ball a little late. That is the commmonest reason that players hits the ball WAY long, like u say u do from time to time.
3] Add some top spin to your strokes, especially when you are anxious cos youre making errors. Putting more of the "energy" of the stroke into topspin will still allow you to take a swing (as opposed to being tentative and just slicing everything on the BH), but give you a far better chance at keeping the ball in court. I'm not talking moon-ball, just aggressive spin with a loop that will keep it in play. Nothing like taking a swing with controling top spin to make you feel comfortable and in control. Does wonders for the confidence.
4] recite before EVERY point. " I am not alex stevenson, I am not alex stevenson, I will not flail at everything" (only joking