Hello, Welcome to Just Answer and thanks for your question. Preventing constipation will make passing feces easier and less irritating so that it isn't as likely to cause bleeding. Often it is necessary to have surgery to remove hemorrhoids to prevent bleeding. Fresh fruits and vegetables, whole grains and lots of fluids help keep feces soft. Some people will also need to take fiber supplements like Metamucil or Citracel.
Then you definitely need an examination and colonoscopy to see why. Some possibilities are one of the inflammatory bowel diseases (Crohn's, ulcerative colitis) or possibly irritable bowel syndrome. Until you know the reason for the bleeding, there is no other way to treat it other than keeping feces soft. If it is already soft, then you have to have medical intervention.