How does aspirin help prevent heart attacks?

How does aspirin help prevent heart attacks?