The answer is simple. It doesn't!
When a person takes aspirin, the pill dissolves in the stomach or, sometimes, in the small intestine. From there, it goes into the bloodstream and it travels through the entire body. Although the medicine is everywhere, it only works where pain-transmitting chemicals are made -- including the area where it hurts.
"If it works so well," you may ask, "how come I have to keep taking aspirin?" Like most chemicals, the body has ways of getting rid of it. With aspirin, your liver, stomach, and other organs change it from acetylsalicylic acid to salicylic acid, the more basic chemical from which aspirin is made.
This chemical slowly changes a bit more by the liver. The liver sticks other chemicals onto the salicylic acid which allows the kidneys to filter it out of the blood in urine. The whole process takes four to six hours therefore, you need to take another pill to keep the effect going.
The problem with aspirin traveling through your entire bloodstream is that your body needs the chemicals that help send pain signals. One place those chemicals are useful is the stomach. An enzyme there makes a chemical that helps keep the stomach lining nice and thick. Aspirin can keep this enzyme from working causing the stomach lining to get thin. Digestive juices then irritate it.