This happens when the ignition switch is all rusted up inside but that doesn't neccessarily mean that all hope is lost and you have to buy a new one.
Because I'm your friend.
Well what you have to do in this situation is go and buy a can of WD40. Its not very expensive, I got it for just 200Rs.
Now spray it inside the ignition switch, not too much a little is enough, you will know when you do it and then take your key and insert it inside the ignition switch for about 10 times and your done.
Do the same with the side lock and some other lock too if you have one.
What WD40 basically does is that it forms a protective film where you spray it and that keeps water away from that place because WD means water dispenser. So use it in places where you do not wan't water to go e.g a lock thats exposed to rain, washroom door's hinges, the outside locks of your car where you insert the key in etc etc.