Oil seals operate by creating a tight barrier between two moving or stationary parts, such as a shaft and housing, to prevent oil from escaping and contaminants from entering the system. This is essential for maintaining the efficiency and performance of the machinery, as well as preventing potential safety hazards.