You are right. It is a small miracle that your software can run on many different computers of different hardware and software configurations. But it wasn't always like that. In the early days of software, it was really difficult feat to achieve. Software had to be built for specific architecture and against specific hardware. And running against different architectures often required additional work.
What changed since then are new abstractions and APIs.
When you build your software, you don't build it against specific hardware. You build it against an APIs. Your software then doesn't care about hardware, it only cares about that hardware providing the API it needs. Hardware vendors are then incentivized to implement those APIs, so that lots of software can run on their hardware. Also, they are incentivized to keep those APIs rock-solid with big focus on backwards compatibility, so that their hardware can run old software.
And the same can be said about third party software your own software interacts with. You should only care about APIs and shouldn't care about who or how are they implemented.
Deploying the binaries themselves then becomes mostly a trivial task. As was noted in other answers and comments, your IDE is not required to run the application. If you look what IDE is really doing, you will see that all it does is to create a normal executable fine and then runs it. If you take that executable and copy it to another machine, it should run without need for an IDE. There are some gotchas like debug vs release builds and deploying 3rd party libraries. But that shouldn't be difficult if you study your language's/IDE's documentation on how to create a releasable binaries.
Licensing is another point. But to simplify it a lot, most 3rd party providers rely more on fear of legal action that any technical solution. They rely on the consumer of their binaries, who is the developer, to make sure their binaries are used and deployed correctly. And they rely on the developer to do it in a way they specify in their licensing.