A VFD creates variable frequency voltages by rectifying the incoming AC voltage to DC then switching the DC on and off, reversing polarity (+ then -) to generate the desired AC frequency and voltage output. Digital control logic determines when each solid-state electronic switch turns on/off. A very basic circuit has six switches, connecting the plus and minus DC voltages to the three phase outputs.
For forward rotation, the A phase voltage switches turn on first, then B phase, then C phase with the proper timing to generate three phase voltages at the desired frequency. (ABC rotation)
When the logic gets a reverse command, it turns on B phase first, then A, then C. (BCA=CAB=ACB rotation).
There is a lot more to VFD controls, logic and switching but the basic idea is the same.