One of the biggest differences that I see between average and good TF2 players is their sense of movement. Sure, you can have great aim, but given how wonky TF2's netcode can be sometimes, that's not always going to carry you. However, the ability to avoid damage and simultaneously give yourself a positional advantage (we'll talk about what that means later) allows you to stay alive longer, and thus be more effective (remember: staying alive is your primary goal here).
The first and most basic aspect of movement is simple strafing. Left, right, forward, backward. These are your directions. Learn them. Everyone knows how to get from point A to point B, but if you've ever watched professional soccer, football, or basketball players, you'll notice that they rarely move in straight lines. Instead, they constantly move from side to side, denying their opponents the opportunity to predict their movements. This is what you should try to do in TF2; quickly switching between left and right strafing will throw off many people's aim, especially more "aim-sensitive" classes such as the sniper or scout. A note of warning, however: if you press and hold a strafe key, and then try and strafe in the opposite direction without releasing the first key, your character will freeze, and become an easy target.
That first section covers the basic x-y axes of movement. To really step your game up, add the z-axis: jumping and crouching. Jumping has its advantages and disadvantages. While in midair, a skilled opponent can predict where you will land, as you cannot easily strafe. Thus, it's foolish to constantly jump around. However, in many situations, simply jumping will save your life.
Take this one: You're defending the badlands spire as a soldier, and you're right at the corner of the stairs leading onto the middle point, in the dirt section by the barrels. Suddely, a heavy turns the corner, and begins to spin up. At this point, you probably can't simply outgun the heavy, because he has a positional and reactionary advantage (he has the higher ground, and started his attack before you). His gun also does more damage per second (dps) than yours, provided that he has good aim. If you simply turn and run, even using the equalizer, you'll probably die. However, if you combine running with jumping, you can utilize the knockback effect of the heavy's bullets while in midair to your own advantage, and get pushed further away from him, possibly escaping death. Of course, as soldier, you always have the possibility of rocketjumping away from a threat, which is oftentimes a safer approach.
If you are blasted into the air by an explosion of any sort, holding crouch + the strafe keys and slowly turning the mouse allows you to perform an air strafe, as seen in this video:
This is a fairly advanced tactic, but an incredibly useful one. It's definitely worth practicing.
If you want to work on your movement, here's a good drill: play sniper on any public server, and try to snipe as close to the front lines as possible. You'll be forced to dodge several varieties of projectiles, from rockets to bullets, and while you will die sometimes, you'll improve both your movement and your aim very quickly. Also, because you'll typically be surrounded by other classes on your team, you're less likely to get backstabbed, which everyone knows is the most frustrating thing to have happen to you as sniper.
Now, for the positional advantage term I mentioned earlier:
Everyone understands this concept, whether they know it or not. An archer shooting from high ground to low ground has a better chance of hitting his target than vice-versa. High ground in general gives you a great advantage in TF2, as you can utilize splash damage more effectively. However, there are many other factors that can go into establishing a positional advantage. For example, the presence of walls, especially sharp corners, or environmental obstacles such as barrels, can give you a great strategic foothold. It's very easy to hold chokepoints (small, easily spammable entrances or exits to larger areas i.e. the doors to the middle point on cp_granary) by using these corners to your advantage: You inherently have cover as long as you don't turn the corner (though you have to at some point) and can tell when an enemy is on the other side by firing a projectile such as a rocket and listening for the hitsound (this assumes you have hitsounds enabled, which you should). It's fairly easy for a single soldier, even at low health, to hold the middle point house on cp_badlands, simply by taking advantage of this principle.
Try these tips out, I promise they'll improve your game!