The Avengers form after Loki enters a portal to Earth, which results in the Battle of New York during the Chitauri Invasion in The Avengers.
The same year, Tony Stark takes over cleaning up New York, which leaves Adrian Toomes angrily out of work and paves the path to the events of Spider-Man: Homecoming.