I mean not just the binary, but its libraries, config files and data (strictly speaking all files). Also when I download a package where is it best to extract it. If I move these files will the app be corrupted?
Most programs follow the Filesystem Hierarchy Standard (man hier): libraries go to /usr/lib, configuration files to /etc, static data to /usr/share, and so on.
Some self-contained programs put all data in /opt/<program>/.
.deb/.rpm packages are not supposed to be unpacked manually – they should be handled by the apropriate program, dpkg or rpm.
If you have only the source code in a tarball, you must extract it to a temporary location (somewhere to /tmp or $HOME). The rest, including installation is usually handled by the Makefile (by running make install); see FHS above.