Why is the momentum in a spaceship traveling in space not conserved?

Can someone please explain? thanks

Not sure that the premise of your question is correct. If the rockets are firing, the forward momentum change in the spaceship plus the backward momentum of the gases ejected add up to zero as required by the law of conservation of momentum. Interactions between the spaceship and other bodies by gravitational attraction also obeys the law of conservation of momentum.

The momentum of the spaceship could increase beyond what the law predicts if it moves fast enough to have a relativistic mass increase.