It is not impossible, but it is fairly rare.
First, a few examples of this occurring.
A collaborator's lab hired a "consultant" who specialized in a few specific techniques. He came for a few months: set up some new equipment, calibrated/adapted it for the lab's particular needs, trained lab members in its use, and then moved on. I think he had been a research scientist and was now semi-retired; he wasn't otherwise affiliated with the equipment manufacturer or university.
Two friends are working as contract coders. They help standardize, document, and polish labs' motley collection of scripts. One of them worked on an analysis "platform" as part of his PhD, and he also helps move work from those ad-hoc scripts onto the platform.
My current lab outsources some fabrication work to a machinist. We don't do enough of it to justify having our own shop, but what we do want sometimes want something with tight tolerances or made from odd materials.
However, these are relatively rare occurrences. Why?
I partially agree with Brian Borchers' answer, but I think it's a bit more subtle than that. Many funders aren't explicitly opposed to contractors, but their policies implicitly discourage them. Trainee labor is relatively cheap, if sometimes in a penny-wise, pound-foolish sort of way, and can be funded in a lot of ways, some of which don't tap into the research funding (e.g, training grants, fellowships, etc). Contractors are more expensive and can only be paid out of the research funds, making them a better fit for projects with large budgets and tight timelines. Indeed, some DAPRA work is done almost entirely by contractors!
Freelancing usually also involves tightly-scoped, easy-to-verify tasks: build the specific thing in these blueprints, write code to connect this to that, etc. Research is often more exploratory and open-ended: not only do you want to implement your proposed method, but also understand it--and perhaps the problem it is intended to solve too. It will be tough to ensure that any lessons learned along the way transfer back to the"research" component. You'll need to verify those conclusions too, along with whatever work product is produced. I think this is often tough to do, and universities have surprisingly little infrastructure that helps with it.