Aspirin works by inhibiting the enzyme cyclooxygenase (COX), which plays a crucial role in the formation of prostaglandins and thromboxanes. These compounds are involved in inflammation, pain, and blood clotting, making aspirin effective for multiple conditions.