Would/could PIs hire a consulting company to do partial work that's not in his/her field
Do you exclusively mean non-academics? Sometimes a collaborator is included in another department or another academic institution to bring in such expertise. This can have it's downsides depending on which agency you are including since there may be costs to subcontracting or collaborating with another entity. It's possible that a Computer Scientist or Engineer down the hall or across campus has the student that can do the work without having to write in a professional contractor, though it is certainly possible to use a contractor. My wife works for a web firm and is currently responding to an RFP from a university to do user experience work for a web-based NSF project.