The way in that this question is framed looks like a false dichotomy.
The very first sentence of a recent book starts with:
NSAIDs are one of the most widely prescribed drugs around the world to treat pain and inflammation.
In treatment we often do want the inflammation to go down if it's overshooting.
In treatment we often do want the pain to go down if it's overshooting.
Advances on this area have proved that COX-1 and COX-2 products are involved not only in pain and inflammation but in cancer development as well. In fact, most outstanding advances in the field where discovered when these drugs were tested to prevent gastrointestinal cancer. These advances and knowledge cannot be separated today from the effects of aspirin on the cardiovascular system and on cancer prevention and treatment. In addition aspirin is still being used for the short-term treatment of cold, fever, and pain.
Angel Lanas: "NSAIDs and Aspirin. Recent Advances and Implications for Clinical Management", Springer: Switzerland, 2016.
There is no pain-receptor to be treated with anti-pain in this class of drugs. These substances were not designed to be anything, they were discovered, and discovered to have an array of effects. They interact with a wide range of receptors, signalling pathways, and have a range of metabolic consequences.
From the "Chemistry" chapter:
This arachidonic acid cascade is of great importance in inflammation, pain, and fever. Prostanoid synthesis is significantly elevated in inflamed tissues, where PGE2 and prostacyclin (PGI2) contribute to this response by increasing local blood flow, vascular permeability, and leukocyte infiltration. These prostanoids also cause peripheral sensitization by reducing the threshold of peripheral nociceptors, while PGE2 and other prostaglandins induce central nociceptive sensitization at the spinal dorsal horn neurons. Finally, PGE2 acts at the hypothalamus to increase body temperature by increasing heat production and reducing heat loss. Likewise, inhibition of prostanoid synthesis by NSAIDs is responsible for undesired side effects such as gastrointestinal and renal toxicities, since prostanoids are physiological regulators of gastrointestinal mucosal defense and renal homeostasis.
Conceptually, reducing inflammation only reduces pain if the inflammation caused the pain. If there is pain that is reduced by anti-inflammatory drugs without inflammation present, then the anti-inflammatory effect observed to be a feature of these drugs will have little explanatory value.
In this case, these drugs can do both, separately or at the same time. There is no "by-product", but a range of effects to expect. If we need just one effect, good, if we need both effects at once, even better.