Once he scratched the itch of being a full-fledged superhero, all Spider-Man ever wanted was to become an Avenger, but he strangely turned down Iron Man's offer in Spider-Man: Homecoming. Needless to say, the excitement was high among Spider-Man and Marvel fans when Sony agreed to allow the web-slinging superhero into the Marvel Cinematic Universe. That meant for the first time in the character's history in live-action he could interact with other big-name Marvel heroes and even potentially join the Avengers at some point.
Two years after his MCU introduction in Captain America: Civil War, Spider-Man was knighted as an Avenger by Iron Man in Avengers: Infinity War. They were on their way to Titan with Doctor Strange when Tony Stark officially made Spider-Man a member of the team and the look on Peter Parker's face when it happened was a combination of honor and shock. To him, it was unexpected but also something he longed for. But the thing is, Spider-Man could've already been an Avenger before the Black Order came to Earth.
Happy Hogan brought Peter to the Avengers Compound at the end of Spider-Man: Homecoming, where Tony offered him membership on the team. It took Peter a moment to take it all in, but he ultimately rejected the proposal because he wanted to remain grounded and simply be a friendly neighborhood Spider-Man. He wanted to help someone find their lost bicycle and give an elderly woman directions. Fighting alongside the Avengers would be exhilarating, but Spider-Man didn't want to accept the cost of taking on major villains and forgoing his private life - not yet.
Spider-Man's decision was ultimately the right choice for him and his story arc, and it was the completion of the first chapter of his journey that began in Civil War. When he got that taste of a bigger life as a superhero, he truly wanted it and vied for it every day by calling Happy, trying to impress him and Iron Man. However, defeating Vulture gave Spider-Man a new perspective on life, one that didn't yet jive with what Tony Stark wanted for him. But when Earth was attacked, he realized it was his duty to intervene. That's why he fully accepts being an Avenger in Infinity War, even going so far as to tell Star-Lord that on Titan.
Interestingly, there was another layer to Spider-Man turning down Iron Man's offer - after all, it wouldn't be a superhero movie if a scene or decision wasn't also a reference to the comics. Before Peter leaves, he turns back around and asks Tony, "That was a test, right?" Not wanting to feel embarrassed, Tony says that is was, even though it really wasn't. That particular interaction referenced Spider-Man originally being recruited into the Avengers in The Amazing Spider-Man Annual #3 in the early 1960s. Thor made the offer in the comics and was equally as taken aback as Iron Man when Spider-Man chose to think it over.