In most cases it will be a combination of several of the factors you describe.
It can be a tuning problem. In this case normally the gear change will work in one direction but not in the other one. If it is only a tuning problem, it may be fixed quite easily by tuning your derailleur correctly. Also for this type of problem it is characteristic that it can occur in both shifting directions depending on the "direction" of detuning.
Unfortunately especially on cheaper derailleurs tuning may not be the only problem. The second one is friction either in the bearings* of the derailleur or of the derailleur cable in the cable hosing or both. In this case the problem is typically much worse in the direction where the the cable is released by the shifter and the spring does the work. Normally the derailleur should jump to its desired position with one sudden step, but if friction comes into play it may creep more or less slowly to its position which might give the chain not enough momentum to jump to the right cog. As cheaper derailleurs are built with simpler bearings they are more prone to such failure. A maybe slightly too weak spring may worsen the situation here.
Another point that you didn't mention is the wear of the derailleur bearings. The whole device consists of several linked parts that are aligned to each other to certain axes. If the bearings in the links are worn out in a way that there's some clearance, the derailleur may bend a bit, changing the alignment of the derailleur in respect of the frame and the cassette. In this case the chain may run from the derailleur to the cogs in an angle that hampers the shifting process.
*As pointed out in the comments there are no real bearings in the links between the parts. Instead the links consist basically of two surfaces that glide on each other. But there is a huge difference in the quality and durability of those surfaces and in how good they can withstand contamination that causes friction and wear.