Why do companies fund academic research?
There is a variety of reasons, as someone who has worked on such projects, here are a few that come to mind:


Access to research facilities. It's often far more rational to fund a study in a university than to invest in building your own wet lab/cleanroom/animal testing lab, etc. In some fields and countries, there are also regulations that limits certain area of research to university institutions (example: research on human tissues).
Highly educated, relatively cheap human resources In the subsets of projects where academic researchers actually do the work from the project description, it is generally cheaper and bears fewer risks than hiring people directly.
Great way of recruiting scientists by establishing a close collaboration, the company has the opportunity to meet and see potential hires in action.
In some fields, it can be a form of advertisement. In particular for companies that have scientists or research labs as customers. Example: lab equipment manufacturer, metrology tools, lasers, etc.



  Do they get actual patents out of it?


Yes. It's frequent for industry-funded projects to result in patents. The patents are usually owned jointly by the company and the academic institution. Sometimes the technology is already patented and the study is only about testing an application. Publishing a technology in the scientific literature can also be a way to prevent other companies from claiming ownership, since you can't patent something that is already published.

Note that industry implication in academic research might diminish, as it becomes evident that they aren't always getting good research for their money. See: http://blogs.nature.com/news/2011/09/reliability_of_new_drug_target.html