@Judge gave a quite good answer on how to follow your steps, but I will point out that there are other steps to follow than those you have listed, which will avoid pseudo-forces.
Are there some other steps to follow when I know that the object is definitely accelerating in one direction or another?
Yes, there are. And I personally find it much simpler.
Specifically, a simple method is to just randomly choose the direction of the static friction and add it to the free-body diagram. In the problem given, it must be either up or down, so let's say that we choose down. Then, when solved, if the result is positive then it was correct and the direction was indeed downwards; if the result turns out to be negative, you have chosen the wrong direction and it is upwards instead. In any case you get it right in the end, because a minus on a force just means that you should flip the force vector.
So, outlined, the steps would be:
a) Draw free-body diagram (for a stationary frame) and
b) draw static friction in a random direction along the contact surface (there are just two choices).
c) Solve the whole thing with Newton's laws as always.
d) When you have found the value of static friction, look at it:
- Is it positive then all is good;
- is it negative then you chose the wrong direction and you must flip it around.
In the problem given, the box on the side would have a free-body diagram with normal force $\vec n$, weight $\vec w$ and static friction $\vec{f_s}$. We set $\vec n$ rightwards, $\vec w$ downwards and let's choose $\vec{f_s}$ downwards as well as are arbitrary choice. Setting up Newton's 2nd law for the horizontal and vertical directions give:
$$\sum F_x=m a_x\quad\Leftrightarrow\quad n=ma\\
\sum F_y=m a_y\quad\Leftrightarrow\quad -f_s-w=0
\quad\Leftrightarrow\quad f_s=-w=-mg$$
It here turns out that the value of $f_s$ is negative, so the chosen direction of the force vector $\vec{f_s}$ is wrong. It should rather be the other way: upwards.
If you had chosen upwards as the direction from the start, the equations would have become:
$$\sum F_x=m a_x\quad\Leftrightarrow\quad n=ma\\
\sum F_y=m a_y\quad\Leftrightarrow\quad f_s-w=0
\quad\Leftrightarrow\quad f_s=w=mg$$
The value of $f_s$ is positive, so the chosen direction is correct: upwards.
The given problem is quite simple since acceleration doesn't have any influence on the direction. If it was an incline moving instead of a wall, it would have. In that case you must know the direction of the acceleration - because you can't have two such unknowns where we don't know the directions. But usually you also do know or is able to easily guess the acceleration direction.
An extra comment to be aware of is that it is often easy to guess/see what the direction is right away before you begin. In the given problem that is possible.
Because, remember what static friction does: it tries to prevent sliding. So, it must always "hold back", when other forces try to start slide. It always "holds back". In your given problem, you can farely easily see that gravity pulls downwards with the weight $w$, so naturally static friction "holds back" by pulling upwards.
This easy and quick calculation-less method of "seeing" the direction is often possible because it often is clear in which direction the other forces (namely the resulting force) pull. But in some cases with many forces present in both directions this is not easy to see; for example if I was pulling up with a rope in the box in the problem. Then I would have an upwards pulling force, and the weight would still be downwards, and then the direction of static friction depends on which of these that "counts the most". If I pull a tiny bit, then the box would fall without static friction to help to hold up. But I pullvery much - more than gravity pulls - then the static friction must hold back downwards, to avoid the box from sliding up.