From an evolutionary POV you can argue that it is all about preserving the gene pool. However, why do people sacrifice for for other creatures that are far from their gene pool.
Yes, behavior that would promote the representation of one's genes in subsequent generations would be selected for since said behavior helped to ensure the survival and reproduction of one's kin who share the genes leading to that kind of behavior.
Evolutionary changes in wetware, such as establishing altruism, can take a long time. What kind of societies did our ancestors live in when they evolved the innate emotional attachments to kin and inclinations to act altruistically for the benefit of their kin? Small tribes in which most members were related to each other, such that sacrificing yourself for a tribe member would very likely mean doing it for your kin -- or Plan B your sacrifice would ensure the survival of the tribe which would protect and provide for your immediate family and other kin.
The social environment in which those emotions, attitudes, and inclinations evolved was very different from our present social environment, but those emotions, attitudes, and inclinations are still a part of us. So our response to the changing social environment has been to adapt what we feel to the new environment. That involves extending our sense of altruistic obligation to many whom we do not share kinship with, even though those "instincts" had originally evolved on the basis of kinship.
So a soldier sacrificing himself to save his "brothers" (not just "buddies" as you try to trivialize their close relationship) is the application of his inbred altruistic "instincts" to protect his kin, but with a very extended sense of "kinship". One which may make no logical sense in terms of actual sharing of genes, but then such acts of altruism are very rarely performed logically.