Question about igneous rocks:

How do igneous rocks form separate inclusions of different minerals, when they are formed out of molten magma that cooled down? Wouldn’t the hot, molten material be all mixed together, (like melted caramel or something)? What causes the minerals to form as a discrete mass, like these olivine and orthopyroxene xenoliths?

How do igneous rocks form separate inclusions of different minerals, when they are formed out of molten magma that cooled down? Wouldn’t the hot, molten material be all mixed together, (like melted caramel or something)? What causes the minerals to form as a discrete mass, like these olivine and orthopyroxene xenoliths?