Many hot Jupiter (HJ) systems have been observed to have their stellar spin axis misaligned with the planets orbital angular momentum axis. The origin of this spin-orbit misalignment and the formation mechanism of HJs remain poorly understood. A number of recent works have suggested that gravitational interactions between host stars, protoplanetary disks, and inclined binary companions may tilt the stellar spin axis with respect to the disks angular angular momentum axis, producing planetary systems with misaligned orbits. These previous works considered idealized disk evolution models and neglected the gravitational influence of newly formed planets. In this paper, we explore how disk photoevaporation and planet formation and migration affect the inclination evolution of planet-star-disk-binary systems. We take into account planet-disk interactions and the gravitational spin-orbit coupling between the host star and the planet. We find that the rapid depletion of the inner disk via photoevaporation reduces the excitation of stellar obliquities. Depending on the formation and migration history of HJs, the spin-orbit coupling between the star and the planet may reduces and even completely suppress the excitation of stellar obliquities. Our work constrains the formation/migration history of HJs. On the other hand, planetary systems with cold Jupiters or close-in super-earths may experience excitation of stellar obliquities in the presence of distant inclined companions.