There are different container formats being used to hold the executable code. There is a huge difference between windows and Linux APIs and also the directory structure is pretty much different in both.
You can write a program that can use either set of APIs and that can handle either directory structure, but you still can’t run the same file on both operating systems because of the difference in container formats.
You can solve this by using Wine.
Want to get in-depth knowledge of Linux, check out this Linux course from Intellipaat.