There is one more major element influencing what you pay at the pump. Unlike everything we've discussed so far, this is the only large piece that exists apart from supply and demand. Whenever you put gasoline in your car, you're also paying your taxes.
Most regions have a sales tax on the goods you buy. That's why a $1 candy bar rings up for $1.08. This percentage rate is usually between 6-10% total. When you buy gasoline, there is also a federal tax, and altogether this equals about a 13-18% sales tax. In other words on average, 47-62 cents of every gallon you buy is going to the state and federal government. (You can find exact numbers for your state here.)
There has been some talk in the presidential race about a summer gas tax holiday. This would eliminate the federal gas tax, which accounts for 18 cents per gallon, for about three months. The benefits and consequences of this tax are debatable but likely minor either way.
Where does this money go? Presumably, taxes on gasoline go to the improvement of the road system and infrastructure.