We must consider earthquake loads when analyzing all members of a structural system. A structure is a whole unit, inseparable from each other. One effect on one member has effect on other members. Therefore we can not just isolate beams and say “earthquake loads are lateral so why do we analyze beams for earthquake”
At the most basic level, the beams hold the columns together laterally and determine the sway amount of the structure, not to mention the torsion effects that the columns and shear walls resists and working together with the beams while doing so.
In short, the structural frame of a building is a whole system that takes into account all of its components when responding to earthquake loads. Therefore, a whole analysis is made on the structure which then determines the loads that fall on the beams.