So your derailleur came off the hanger, or did the hanger come off with the derailleur? in either event, its now gone through the spokes and is stuck there? there is no way to get it out of the spokes. I assume the chain is still in the derailleur, you might try taking the chain off, if you have a chain pin remover. If not, just try to get it out.
As for what is causing it...
What type of bike and derailleur is it? maybe either the threads on the mounting bolt or where you mount the derailleur on is possibly getting stripped, thus it is not holding all the way? maybe you didn't tighten it enough? if a bike store last serviced you deraillleur, see if they torque the mounting bolts to spec...
A pic would also be worth a thousand words here