Does the output of a compiler depend on the OS you are using?

In the company I am working in we have a management software, written by an external programmer. Let’s call the software PK. PK was initially written in the 90s using C++. Since then it was regularely updated and maintained but in its core it always remained a software based on 90s technology.

We are currently in the process of migrating from Windows 7 to Windows 10 and I recieved one of the first Win 10 PCs in order to test if everything works as expected on the new OS. Everything worked but PK. PK suddenly had frequent crashes. I told the software developer that there are issues with PK under Win 10 but even after numerous updates and changes to the code we still had these crashes. The developer just couldn’t figure out why it crashed although it seems to be related to the memory management of PK.

The last straw the developer saw, was to compile the software on my Win 10-PC. I compiled the source code with exactly the same version of Visual Studio 2008 and suddenly it worked. No more crashes.

So my question is:

Can it be that the same Code, compiled by the same compiler produces a different binary dependent on the version of Windows (Windows 7 and 10)?

And if so: Why?