Immunomodulators function by interacting with various components of the immune system. They can affect the production and activity of cytokines, alter immune cell proliferation, and influence the maturation and differentiation of immune cells. These actions can either boost the immune response to combat infections or cancer or suppress it to prevent excessive inflammation and autoimmunity.