Could be due to the nature of capacitors - Some of mine do sometimes TBH.
Capacitors act as storage for electricity that can be used reserve of power
or to smooth out an electrical supply or as a signal filter.
One thing a capacitor will do, is if presented with a low enough independence
circuit they will dump there load so to speak instantly.
Capacitors can release a very large current and in essence could be the
effect of the spark your seeing as it discharges right at the point when
you connect the cable.