Actually, part of this is by design.
Software companies turn a blind eye to students and faculty pirating their software, so the students learn how to use their program. Once they go on to companies, they will request to use what they know best, and the companies will pay the hefty fees.
How can we avoid this? The best solution is at the root: replace all commercial software by open source versions, when this alternative has a comparable level of quality. This has two costs that would have to be weighted before doing the switch:
- The instructors would need to learn another software, that is perhaps not what they are using for their research.
- If the industry standard is a commercial software, the students will have to learn it, preferably when still at university.
On the other hand, sometimes the open source version is superior to the commercial version. For example, I think the Scipy ecosystem is much better than MATLAB except for a few niches. So, when MATLAB users do the exercise of evaluating the quality of Scipy for their applications, they may discover that making the switch in both teaching and research is, perhaps, a good move.
This switch should be encouraged even more for introductory classes, where none of the advanced features come into play, and classes where the software is only used marginally (limited to, for example, one or two practical sessions). Once students have knowledge of the free alternatives, they would have alternative resources before pirating.
(Disclaimer: I personally dislike MATLAB quite a lot, but I know of many people from many fields that are making the switch, and of no one that is doing it back. YMMV.)
Another front is in the software companies themselves. My university provides some commercial licenses for free for us staff. But the list of instructions to install and launch some of the programs is as long as my arm, and quite often (judging from the emails the IT department sends), unreliable. So, even though people can get a legal version for free, the pirated version may prove to be easier and more reliable; so I wouldn't be surprised if several people had chosen that option.