A Hardware Security Module (HSM) can come in various shapes and forms; there are smart cards, PCI cards to plug into a PC, usb tokens, separate boxes that communicate over channels like TCP/IP, USB or rs-232, etc. Regardless of shape or package, the main purposes of these modules is usually either:
But of course, there could be other purposes.
Some modules may be able to offer both, but more often than not this is not the case.