Yes, you can have a vasovagal syncope in response to a pain stimulus. The cardioinhibitory or vasodilatory response results in a drop in heart rate or blood pressure, leading to fainting.
I don't really know why your body responds in such a way, my speculation is that it might be our evolutionary-left-over way of playing dead in a dangerous situation?