The gas prices dropped to a low during the pandemic because of the pandemic. Enough people were staying home that carbon emissions dropped to a record low, and because so few people were driving, the price for gas dropped. As u/mmmSaucyPasta said, basic supply and demand in action.
As far as the gas prices raising recently, that has more to do with the war between Russia and Ukraine, and so many countries now refusing to purchase oil from Russia in response. The US is one of those countries. Having to find new oil sources is expensive and doesn’t happen immediately. Now with the supply lower because of the war, the demand is just as constant and rising. Higher prices. Again, supply and demand.