The money they spend on sales and marketing won't include the $263 million they spent bribing law makers (they have three lobbyists for every member of Congress) or the dark money they're spending on bribes we're not even allowed to know about.
They also spend money making tiny tweaks to existing drugs that work just fine for the sole purpose of extending their patents and keeping drug prices as high as possible (https://en.wikipedia.org/wiki/Evergreening)
A lot of basic research is government funded, i.e. grants for ongoing research at public universities, but except in extreme outlier cases like the global pandemic, private biotech companies don't get free government handouts for their drug research, and certainly not in meaningful amounts. For perspective, privately funded medical research spend is more than 5x the total NIH budget, and only a portion of the NIH budget actually goes to drug research.
They indeed do get plenty of free government handouts for R&D. Their labs take a fortune in NIH grants. Sure, a lot of that is to public institutuions but plenty goes to private labs.
They also spend money making tiny tweaks to existing drugs that work just fine for the sole purpose of extending their patents and keeping drug prices as high as possible (https://en.wikipedia.org/wiki/Evergreening)