Why does AC charge the capacitor?
AC supply consists of positive voltage half cycles followed by negative voltage half cycles. During the positive voltage cycles, the capacitor gets charged to a positive voltage. During negative cycles the capacitor gets charged to a negative voltage. In between, there will be some time instants where the capacitor gets discharged to zero volts (when the AC supply passes through zero volts).
If you unplug a capacitor while the AC was some non zero voltage, the capacitor retains the charge and the voltage just before un-plugging.
When you then short the terminals, the stored charges gets a path and the capacitor discharges; usually accompanied by a spark if the voltage was high.
Note
The charging rate and discharging rate of a capacitor depends on the external circuit connected to it. At any given time instant the capacitor is either charging or discharging or holding its charge; but not charging and discharging at the same time instant.
Warning
Directly plugging the leads of a fan capacitor to AC supply is dangerous. The capacitors usually have a metallic body and any damaged capacitor can allow the AC supply to be conducted to this metal body. If you are holding the capacitor with bare hands, you can get a serious shock from the supply. Even if the capacitor is good, accidentally touching the leads can also shock you.