Well, there are multiple reasons, but the most encountered one is the nut keeping the strings fixed. While you play with this kind of nut the strings cannot move in the headstock part, the one between the tuners and the nut. There are many reasons: improper gauge strings, badly cut nut, bad tuning pegs, and so on.
There are several ways you can solve this:
1. If the nut is stiff around the strings you can take a polishing cloth, stick it to a small cardboard the size of the current string and carefully polish the nut where the string is located. For this you will need six ( or how many strings you have on your instrument ) cards with a polishing cloth sticked to it measuring a total length equal to the gap width of each string. This should be done with the strings off or at least untentioned, because you need to have access to the spaces in the nut. After each phase of polishing the string should be tested to slide with no friction through the nut gap.
2. Even if you have or haven't done the first step, you can surely take advantage of the second one. To decrease friction you can apply graphite in the spaces of the nut to help the string slide more easily. If you do not have graphite or do not want to buy a can of it from the store you can use your pencil. That's right, the pencil, either mechanical or made of wood, but not coloured. The colour ones do not contain graphite, but wax or oil. The best way to go with a hard lead pen is to take a hammer and make powder out of it and then apply it, with a soft lead mechanical pen you can just fill the space in the nut. It is important that the soft pen is mechanical because otherwise it will open the space in the nut too much.
3. You can also elongate the strings while applying the graphite. Especially when replacing the strings you need to pull them a little bit just so that they will not stretch when you are playing, and go out of tune.
4. If graphite does not work for you you can use powder teflon.
5. Another method is putting small V shaped fine sand paper strip in the V of the nut. If the sand paper is too abrasive it will stop the string from moving which is exactly what we are trying to avoid, and if it is not abrasive enough it will go out of place or it will fill the V in the nut making the string unable to slide. This is important to say because when you test the tremolo you want the sand paper to do it's job without making the V in the nut too deep, or fall out of place. After moving the tremolo back and forward a number of times you can get the sand paper out of place and see if it will go out of tune. It is important to take the sand paper out frequently so as not to dig in the nut.
6. If you want to solve the problem once and for all you can switch the nut with a teflon one which should reduce the problem a lot. ( How to replace a nut ).
7. Adjusting the height of the bridge can help a lot, especially if you rise it to make a floating bridge. This will make the strings go further away from the nut, or anyway, not press so hard down on it.
8. Replacing the nut with a locking nut. This will lock the strings so they will not move even when using a tremolo ( the string part on the headstock does not bend ).
9. You can move the strings up the tuning peg more than usual to get a smaller angle between the string and the nut.
10. Adjust the claw. The tension in the springs and strings tends to be the same, and it should be before you start playing. You need to angle the claw in the back of the guitar so that the tension on the bass strings is greater than the one in the the thinner strings ( make the springs on the bass strings more tensed ) .
11. The most drastic thing you can do is to replace the bridge with a roller bridge and attach a Bigsby, if it does not have a tremolo. Even harder, you can mount a Floyd Rose.
12. You can mount locking tuners to prevent the tuning pegs from rolling when using the tremolo.
13. Try fitting higher gauge strings in the V cuts of the nut and maybe some soft sand paper and rub it against the nut. Then, fit your normal strings. You can play a while with the higher gauge strings to naturally make the spaces in the nut larger.
14. Try using the tremolo until the instrument goes out of tune. Retune it and start until it does not go out of tune when you are using the tremolo.