What does it mean when u spit blood sometimes not when I brush my teeth?

Gum Issues. Bleeding upon brushing is not normal. It is a sign of gigivitis or possibly gum disease. You should see a dentist as soon as possible. It is much easier to treat in the early stages.
Periodontitis. Bleeding gums is one of the signs of gum disease and this can be bleeding even when you don't brush your teeth. Seek out a dental professional (dentist or periodontist) for a consultation.
Many possibililities. Spitting up blood once awhile, e.g. 1x/yr, might just mean that a tiny blood vessel was torn somewhere along the nasal, oral, food tube, or breathing tube passages, ex: when someone has a cold and blows one' s nose aggressively. However frequent spitting up of blood could indicate a bleeding disorder, a growth, an infection, among other causes along these same areas. See doc if occurs much&often.