NSAIDs function by inhibiting enzymes known as cyclooxygenases (COX-1 and COX-2). These enzymes play a critical role in the biosynthesis of prostaglandins, which are mediators of inflammation and pain. By blocking these enzymes, NSAIDs effectively reduce the symptoms of inflammation, pain, and fever.