It is, in general, not all that important at all, unless the students wants to claim a lifelong passion for the field.
It can help for majors like CS or various engineering majors, but mostly to demonstrate strength in math. So somebody who wants to apply for Mechanical Engineering, does not need ECs which are related to mechanical engineering, but participation in any math-related EC, such as Math Olympiad, would help the application.
For life sciences, again, it does not have to be related to the major, but a demonstration of science abilities is helpful, though not required. Many students are accepted as biology majors without a single EC related to biology on their resume.
Most importantly, many, or even most, of applicants do not really know what major interests them, or change their minds while at college. So nobody really expects a high school student to know what their college major will be when they are just starting high school.
Mostly colleges want to see that a student did more with their time than hang around wasting time after school. They also like seeing students who have a history of overall success, which is why colleges also like to see students who won awards, and, in general, it is more common for a students to win awards in fields in which they are interested.
All that being said, the vast majority of non-profit four year schools do not look too deeply, or at all, at your ECs, and are more interested in your academic achievements. As a rule, public universities, even “elite” ones like Berkeley or UMichigan, put far more weight on academics than on ECs. “Elite” private colleges weigh ECs more heavily, though even there, an applicant generally needs to have strong academics to be competitive.
For colleges which put a large emphasis on ECs, it is better to find ECs related to one’s interests and passions, and do one’s best at them, than to try and guess “what colleges like”, and select ECs based on that. It is very difficult for a person to excel in an activity that they do not love, and are doing because they think it looks impressive.
Colleges which care about these things want to see drive, passion, tenacity, resilience, and success. “Checking the boxes” and doing “the right things” does little to impress AOs.
So, to reiterate, it is not very important, or really not important at all, for high school ECs to be related to the major which is on the college application.