When programming in languages such as C/C++, one needs to be aware of which libraries the program is dependent on. Usually, these libraries are available with different names on the standard package managers on different operating system platforms such as Fedora Linux, Debian Linux, macOS etc. Occasionally, these libraries may not even be available on certain platforms. So, the only option may be to try one’s luck in compiling and installing the source code.
On the other hand, newer languages such as python and java try to be as platform-agnostic as possible. So, in theory, programs written in these languages should be able to run on any platform. This is true for the most part. Where it isn’t true is where they are not written in pure python or java and combine some C/C++.