Double hung windows you mount on the 2 sashes in the middle where the locks are. You mount the magnet on the upper window glass. It has to be a slim magnet to be able to open the window like a honeywell 5811.
Door, you want the sensor close to the opening edge. Traditionally they were wired so the magnet usually goes on the door itself. If the door does not close firmly either tighten it up or you will need to move the sensor closer to the hinge to avoid gusts of winds and such from triggering it.