"Observation" is just a collision. A photon "knows" it's being observed because that means it hit something else.