Hi, and welcome to Just Answer!
I'm assuming your fan is working correctly, you just intermittently can't control where the air comes out correct?
The doors that control the airflow in your heater box are controlled by electric motors. It's fairly common for the doors to break, often times the splines strip out.. When this happens they will typically work intermittently.. The controller tries to move the doors, if they catch and move great.. if it see's the motors move to far it will stop trying to move them, generally until the next time you cycle the ignition key.
Most often on the 03-04 trucks it's a broken door(s). They have released a technical service bulletin on the issue and some revised parts (heavier duty and less prone to breakage).
Now for the bad news, the dash has to come out to replace the door(s). There are two that need to be addressed, and I strongly recomend changing them both (even if only one is broken). Typically it's the door that changes the airflow between the defroster and the panel vents that breaks, but occasionally the floor door will go out also, so change 'em both at the same time.
That's the worst case scenario, it's possible it could just be a simple calibration issue. Disconnecting the negative terminal on both batteries for about 10 minutes will force the heater control head to recalibrate itself when the power is restored, it's doubtfull but this may correct the problem.
Odd's are very good that if they scan it for fault codes they will find a panel actuator overtravel code stored in the heater control head though, sorry for the bad news.