In space, rockets propel themselves forward by expelling mass at high velocities, according to Newton's third law of motion: "For every action, there is an equal and opposite reaction." The exhaust gases expelled by the rocket create a force in one direction, which generates an equal and opposite force propelling the rocket in the opposite direction.
The key concept here is that the rocket does not need anything to "push against" in space. Unlike on Earth, where vehicles push against the ground or air for propulsion, space is essentially a vacuum with very low density and no substantial resistance. Therefore, the rocket can generate thrust and move forward by expelling matter at high speeds.
Inside a rocket engine, fuel and oxidizer are combusted, producing high-pressure gases. These gases are then expelled through a nozzle at the rear of the rocket at extremely high velocities. According to Newton's third law, the expulsion of the gases in one direction generates an equal and opposite force that propels the rocket forward.
It's worth noting that rockets require a source of propellant to generate thrust, as they carry both fuel and oxidizer on board. Once the propellant is expelled, the rocket needs to be refueled or reloaded to continue generating thrust.