Is amenorrhea caused by eating habits or being underweight?

If significant loss. Lack of menses when previously established (secondary amenorrhea) can result from many causes including depression, rapid change in weight (excess or loss) and various endocrine causes such as hypothyroidism, pcos (and of course pregnancy) . If your eating habits is very selective and poor resulting in significant decrease in body mass index (bmi), then your menses may become erratic and spotty.
Yes. The female body need at body fat percentage of 17-18% in order to maintain a period.