I’ll try to help out here:
if I understood correctly, when at mid-close range, you tend to panic and just spam random attacks hoping to connect.
If this is the case you should try to focus on playing footsies and developing them gradually:
I would start by developing blockstrings. You could just start by walking up to your opponent in mid-close range situation and poking into a blockstring (or hit confirming for better dmg); this should give you confidence in getting out of a bad situation by not letting down your pressure and in the same time being safe.
After that You should focus on the main problem: MOVEMENT
go into training mode and learn all the ranges on your main pokes; try to also learn the ranges of the main pokes of your more common matchups. Then set the CPU to walk a bit, poke and block immediately after. Now try to hit the computer with your poke just after his poke.
This should teach You:
how to stay out of the opponent pokes but in the same time be able to poke him back.
Now that you know the ranges of pokes, you should try to learn movement methods to land those hits.
You can walk in and out of the opponent poke ranges, you can dash in and out to surprise him or to get out of a dangerous situation, you can neutral jump to control space, you could jump back if you need some space or jump in if you want some aggression (either crossing him up on not). All of these movement methods can be dangerous to use under some circumstances, so you’ll have to learn when to go for each of those options basing your decision on your character selection (can divekick? fast walkspeed? etc.), your opponent character and ofc reads.
hope I was helpful