This is only speculation, but I could see it go down as something like this:
Avengers 2 starts out with the team doing a job, and they fight against Quicksilver/Scarlet Witch (among others) and we are introduced to those characters. The job is finished with those two getting away somehow, and we get the story of how Ultron is created, takes control of himself and becomes a giant threat. Somewhere in the middle to the end, Quicksilver/Scarlet Witch realize that they are fighting for the wrong side and need to team up with Avengers to stop Ultron, otherwise there won't be much of a planet left, and so Quicksilver/Scarlet Witch fight along side Avengers in the final battle. As for Vision, I would assume he's like a bi-product of Ultron, or somehow created in the same process, and he ends up helping Avengers that way.