I am by no means an expert in physics, but from what you described it seems clear that the current flowed through the compass, through you and then to earth.
The spark only occurs when the 'easiest' way for the circuit to complete is by jumping from one net to the other (like when a mosquito bridges the gap). One net is at a high potential, the other is at a low potential. Similar to how water at the top of a waterfall flows, when you bridge the gap current flows.
In this case, you bridged the gap with your compass, but you were touching the compass, and you were earthed to the ground. So instead of the charge in the high potential net flowing to the low potential net, the charge flowed through you to the earth, which is at zero potential - even less. You can think of this as digging a hole at the bottom of the waterfall. It now has farther to fall, so it's not going to stop where it stopped before.
I wouldn't recommend doing this again - but you should have made sure you were well insulated from the compass. If there's a plastic handle, hold that, or wear thick insulating gloves. Also - definitely wear shoes. If you've ever tried touching an electric fence in bare feet, you'll know that having no insulation from the earth makes this much worse.
I have tried to keep this answer as non-technical as possible - partly so that it's understandable (I don't know what level of physics you have) and partly because I am no expert myself.
As for how dangerous it could have been - it seems that you have reached the peak danger from a mosquito net. Please, please please don't mess with electricity like this - especially not mains electricity. A mosquito net might be uncomfortable, but if you did the same with a mains socket you could very easily be killed. Electricity is no joke.