– Xochielt Sanchez
Answer by Joshua Engel:
It's precisely because of gravity that they go upwards. The gravity is pulling on both it and the air. The air, being cooler and thus denser, puts pressure on the lighter flame when it is displaced. That pressure is stronger on the bottom than the top, and pushes the flame upwards.
When the gravity is absent, the cooler, denser air doesn't flow downwards. It continues to put pressure on the flame from all directions, which means it comes out as a sphere rather than going upwards. This is what a flame looks like on a space station:
The bottom is flat because it bumps into the candle wax, but otherwise it's effectively a sphere.