Spies are pretty difficult to play, but there are a couple of strategies that I've found that work. Don't start the game out initially as a spy, unless you are going for the Head of the Class achievement. Being a spy is almost impossible to pull off when everybody knows where everybody else on their team is supposed to be.
When you do change to spy, if you don't use your cloak, disguise yourself as a soldier or heavy and run towards the enemy team shouting for a medic. This makes you seem like you're looking for some help before assaulting your team's position.
Another tactic is to disguise yourself as a sniper. Not many people pay attention to the snipers perched at their base's vantage points, so you can get a pretty clear view of what's going on. You'll have to cloak to get into position, but once you're there, you are pretty much set. I'll usually use my view to spy on the enemy and report back to my team, then set up an assault so I can unleash the sappers at the right moment and not draw too much suspicion from the enemy beforehand. This tactic is especially effective in Hydro, not as much in 2fort.
Also, if you manage to get away if you are discovered, change your disguise. I can't tell you how many times I've heard "Spy is a Pyro" only to find no Pyros anywhere nearby, then get backstabbed by a scout or something.
Marsz, marsz, Dąbrowski,
Z ziemi włoskiej do Polski,
Za twoim przewodem
Złączym się z narodem.