Every time I die in TF2, I see that the spawn wait time changes... sometimes, it's a quick 7-10 seconds and another time it's a hefty 17-19 seconds. What determines this? Is it how far you are from the base? Whether your team is winning or not?
There are set times when respawns happen, every 10 seconds by default. So if you spawn just after the timer has reset you will have the maximum wait. Wait times also vary by map and game type, so it can be anything between 5 and 20 seconds.
From the TF2 wiki:
Team Fortress 2 manages its respawn times in waves. The default respawn wave is 10 seconds. This would mean that players are spawned every 10 seconds. However, unless the server population is low, you will most likely have to wait for the wave after. In this case, the maximum respawn time any individual would have is 20 seconds.
Source: TF2 Wiki - Respawn Times page