Side walls can be your friend. Or they can be your enemy. Practice lightly scraping them with your swing.

The idea

Being confident about hitting a ball that is very close to or touching the side wall isn't luck, it's practice. When you swing, your racket should lightly scrape against the wall. The lighter the scrape, the better. Another reason to become confident near the walls is to avoid breaking your racket.

What to do on court

Stand with your arm straight out holding a racket that touches the wall. Now take half a step closer and start swinging the racket so that it touches the wall in the middle of the swing. Don't swing hard, but control the racket. If you want to, place a sticky note on the wall at various points and try to knock it off. Do this on both sides of the court until you become confident that you can hit a ball touching the wall without your racket "hitting" the wall.