In space, there is no friction or air resistance to slow down the rocket. Therefore, it can travel vast distances without needing to constantly propel itself. However, if the rocket changes direction or needs to alter its speed, it will need to fire its engines again to apply an external force and modify its motion.
It is worth noting that rockets use propellant (usually a combination of fuel and oxidizer) to create thrust by expelling high-velocity gases through their nozzles. By Newton's third law of motion (action-reaction), this expulsion generates an equal and opposite force that propels the rocket forward. Once the propellant is exhausted or the engines are turned off, the rocket will continue moving due to its inertia until another external force acts upon it.