|"I want to transfer Windows 95 from one old computer to another old computer. Only the Windows program itself, no other files."|
You need a Windows 95 CD, or at least the complete contents of the \Win95 folder on it, in order to be able to do exactly that.
Do you have one / that ?
If you transfer a hard drive that has already had Win 95 installed on it when it was in one computer to another computer that has a mboard with different hardware and try to boot from that hard drive on the other computer, Win 95 will attempt to load support for the different hardware and the desktop will probably eventually load, but it's likely Windows will ask that you supply the Win 95 CD to install software for some things, unless the hard drive was in a brand name system and has the \Win95 folder and all it's contents that's normally only on the CD. If that's successful you could uninstall all the software you don't want, delete what you can't un-install.
"I have a program that I want to use but it only operates with 95 or 98."
Which program ?
What operating system are you trying to use it in ?
E.g.in 2000, XP, Vista, and Windows 7, you can use a 95 or 98 compatibility mode, or you can often run a third party emulator program.