Endocytosis and Exocytosis
Endocytosis means engulfing so is more likely to occur during phagocytosis where a phagocyte engulfs a bacteria or pathogen.
Exocytosis means releasing something out of the cell and is most likely to occur when secreting enzymes or molecules packed.
Endocytosis enables the cell to take in the bacteria or fluid droplets from out side the cell and this is important for defense and nutrition respectively. Exocytosis is important for the cell to secrete products like hormones or enzymes to the outside so other body parts can make use of them like insulin and digestive enzymes from the pancreas.