Lysosomes are formed through the fusion of vesicles containing digestive enzymes with endosomes, which are membrane-bound compartments involved in the transport of molecules within the cell.