The capacitor has a charging process and a discharging process. In a DC circuit, a capacitor is charged and stored, and a certain DC voltage can be measured. When fully charged, the capacitor will block the DC current. When the capacitor is discharged, a current will appear again until the discharge is complete, and then the current will stop until the next charging process begins. Direct current does not change polarity, therefore, the charging or discharging process must be started by switching the circuit.
Figure 1 shows a basic switching circuit that can start the charging and discharging process. The working steps are as follows:

1) S1 and S2 are disconnected, and the voltage on C is 0V.
2) S1 is closed.
3) C starts to charge, and the current flows out from the negative terminal of E, through R1 and S1 to the positive terminal of E. C charges to the voltage of E, and then the current ceases.
4) S1 is open and S2 is closed.
5) C begins to discharge, and the current flows from the negative terminal of C and returns to the positive terminal of C through R1. When the voltage on C is zero, the current ceases.
In fact, the current does not really pass through the capacitor, because the dielectric between the capacitor plates is an insulator. But in the external circuit, there is indeed current flowing back and forth, and it looks like there is current flowing through the capacitor. During charging, electrons leave the capacitor plate connected to the positive electrode of the battery, and enter the plate connected to the negative electrode of the battery through an external circuit.
The capacitor does not block the alternating current and allows the alternating current to flow back and forth, because the alternating current is constantly changing its polarity, which is equivalent to continuously performing the circuit switching process shown in Figure 1. Figure 2 shows the process of AC charging and discharging the capacitor. The sine wave changes its polarity every half cycle. In the positive half cycle, the capacitor is first charged to the external voltage, and then discharged when the external voltage drops to zero. In the negative half cycle, the capacitor is first negatively charged to the external voltage, and then discharged when the external voltage rises to zero. As mentioned earlier, no current flows through the capacitor, but there is indeed current flowing back through the external circuit connected to the plates. (The capacitor symbol in Figure 1 and Figure 2 represents a non-polarized capacitor, which can be used in DC or AC circuits.)

For a capacitor being charged, the current increases faster than the voltage increase, because a discharged capacitor is similar to a short circuit. The current passing through the short-circuit point is very large, and it takes a certain amount of time for electrons to move from one plate to another. The voltage of the capacitor will increase with the charging process.
In Figure 1, the current in the circuit will increase to the maximum immediately after the switch S1 is closed. In a low-resistance circuit, when the voltage across the capacitor just starts to rise, the current has reached its peak value, so the current and voltage are not synchronized. Figure 3 shows the phase shift between voltage and resistance. In a purely capacitive circuit, the current leads the voltage by 90°. When a resistor is added to the circuit, the phase shift between the power supply voltage and current will decrease.

In Figure 3, the charging and discharging curves are sine wave shapes. When the external voltage E just starts to rise in the positive direction, the current I has reached the positive peak value. When the external voltage reaches its peak value, the voltage across the capacitor also reaches its peak value, and the current drops to zero. When the external voltage begins to drop, the capacitor begins to discharge, and the current in the circuit begins to flow in the reverse direction. When the external voltage drops to zero, the capacitor voltage is zero and the current reaches a negative peak. When the external voltage crosses below the zero axis, the capacitor begins to charge in the reverse direction. When the external voltage reaches a negative peak, the current drops to zero. When the external voltage rises toward the zero axis, the current begins to flow in the positive direction and rises toward the positive peak value. When the capacitor voltage reaches the zero axis, the current reaches the positive peak value. Please note that the current always leads the applied voltage in phase.