Practice, practice. It's the easiest way to get good at spy. I've spent about four hours straight just practicing stair stabbing on tr_walkway.
I also recommend two things:
1. Don't practice with bots. They know that you're a spy and will react accordingly. Real players tend to be much more unobservant.
2. Avoid going directly for one target. Strafe a bit and move where there are no obvious targets to make you look more legitimate.
3. Backpedaling is godlike. If your disguise is injured, backpedal and call for medic. A lot of players won't expect you to be a spy.
4. Hit b to change your weapon. This includes pulling out your sapper and changing weapons, so you can go as a medic with the medigun or a pyro with the flaregun. Since most spies don't know that you can do that, it makes you look more legitimate.
Lastly, to reiterate: PRACTICE. As with all good things, it takes practice to get good at.