The idea that a hypervelocity round will penetrate a ship and pass through depends on one important assumption: there is nothing of significance to hit within the ship. And that implies that the ship has low density (i.e., lots of empty space). In fact, that is a pretty extravagant way to design a spacecraft, and our current technology demonstrates it's not true. Imagine if you shot a round through the ISS. How many different shots could penetrate the hull without also intersecting any other systems?
You don't need to hit something explosive to cause damage. You just need to hit something active, because odds are, the crew probably depends on that thing to operate (they depend on the hull as well, but that can be patched for pressurization, especially if you punch a clean hole through it). Also, the more things you hit inside the ship, the more chances you have to distribute your projectile velocity in very destructive directions.
A smooth hull will generally expose a more or less uniform surface which will not redirect a projectile in any preferred direction. But operational equipment will typically have an amorphous shape and density which will quite likely randomize the redistribution of kinetic energy
The thing about metal is that when you break it, it doesn't just deform like putty. All metals have a certain amount of brittleness to them, and when you bang on them hard enough, fragments will break off. This process is called "spallation". So when the penetrator cracks the hull, some of the damage will manifest as spalled fragments turning the inside of the hull into a small grenade. The magnitude of spallation will depend on the size and density of the penetrator, as well as the thickness and composition of the armor. Bigger, thicker armor that might appear on a warship will produce bigger, thicker spallation fragments.
Of course, it is not only the hull which will produce this damage stream. Anything else impacted by the penetrator will also produce spallation damage. Equipment, internal struts, pipes, etc. can all be turned into miniature fragmentation grenades by a suitably energetic penetrator. The penetrator itself will not survive entirely intact, even if it has enough momentum to exit the target. In particular, the initial contact portion of the penetrator will almost certainly turn to shrapnel inside the target, as happens with APFDS rounds penetrating armor today.
The penetrator will convert its kinetic energy to thermal energy to compromise the hull. This thermal energy will mostly stay inside of the target ship until it is dissipated. If there's oxygen atmosphere inside, it will likely start fires (by providing well more than enough activation energy for deflagration). Any objects inside the ship which are struck by the penetrator will simply give it more opportunities to trade KE for thermal destruction.
The penetrator itself will also absorb much of this thermal energy, compromising its integrity. Some penetrators are designed to fragment once inside the target. Tuning this will require matching rounds to armor, which might be feasible for a well-armed navy, but likely not for opportunistic pirates. A perfect penetrator/shot will convert all its KE into shrapnel/thermal damage inside the target, without exiting. Making this happen consistently is probably not feasible, and would likely depend on a certain amount of luck. Even so, I would not count on railgun shots leaving clean holes in ships without much collateral damage. That's just too convenient and ignores reality.