This is a common bug referred to as the "infinite vision cone" bug where one of the guards will have infinite vision range. So, no matter where you are on the map, you will get detected. If this happens. restart your heist. Unfortunately, there is no work around for this bug.