As long as they use the same connectors (IDE, SATA or whatever), a hard drive intended for use in one machine will function just as well in another (as far as the actual device is concerned).
However if you were thinking of swapping two drives from existing machines (with Windows, or another operating system, already on them), you'd need to remember that the drivers for the hardware in Computer 1 might not be on the drive that you've taken out of Computer 2. So you might end up having to work out which drivers are missing and then find a way to reinstall them.
If you're actually looking for a new drive for any machine these days though, I hope that you'd forget about hard drives anyway and use sold state drives instead anyway.