How does Guardians of the Galaxy fit into The Avengers movies?

Well, in the final few films for the upcoming Phase (Phase 3), it's pretty clear the main villain is Thanos. and if you can remember, Thanos was is GotG and he was in probably one of the most memorable scenes of the whole film. Also in the film, there is one of the six Infinity stones, something Thanos will gain control of sometime in Phase 3 and will use in the Avengers: Infinity War films.

If you're talking about the group, well, the Avengers and the Guardians have a common enemy, who is Thanos, and they will most likely crossover when facing Thanos in the Infinity War, that is if the Guardians have a role in it at all, which they most likely will.