Ultrafast Photoswitching Dynamics of Azobenzenes with Intra- and Intermolecular Constraints