The event horizon forms when a star collapses under its own gravity, leading to the formation of a black hole. When the star's core contracts to a critical size, it creates a region where spacetime is curved to an extreme extent. This curvature traps everything, including electromagnetic radiation, within the event horizon.