They are usually caused by dryness of the nasal lining plus the normal rubbing and picking that most people do when the nose becomes blocked or itchy.
Vigorous nose blowing can also cause bleeding.
People who have nasal allergies are more likely to have nosebleeds because they rub and blow their noses more. Lean forward and spit out any blood. Sit up and lean forward so you don't have to swallow the blood. Have a basin available so you can spit out any blood that drains into your throat. Swallowed blood is irritating to the stomach and can cause nausea or vomiting.