When get is high, LFO passes through to VCO FM input, when it is low, S&H freezes and sends out LFO CV value at the time of the gate change.

When gate is high, 5v goes to switch, letting signal straight from LFO to go through. When gate is low, switch instead outputs signal from S&H to FM in of VCO.

Gate to S&H control in first is inverted so becomes -5v when high, 0v when low. Then it is run into a +5v offset so that when it is high, the control signal going to the S&H is 0v but when it is low, it goes to and stays at +5v so the S&H samples only then and holds that value.

To reverse (value held when gate high, LFO passes through when gate is low) just swap that A & B inputs into the switch and send the normal gate into the S&H control input with no inversion or offset.