If you buy it by purchasing newly issued shares, then the money does go directly to the company and the existing shareholders stakes are diluted.
The effectively takes the bailout money away from the stockholders, which seems appropriate, since their shares would be worth even less if the company were allowed to fail.