Why they team-up?
Heroes aren`t, of course, the only ones who are able to do great things. That`s why, the heroes and villains combined strenght can be the key to saving the world. Villains may also be willing to do something a hero wouldn`t do (for example, something that would require a conscience). If the hero lets the villain do so.
Sometimes there`s no other options but to team up with the first person they run in to.
Usually the villain only decides to work with the hero, if the villain in question has something to lose or gain, or the villain is an antivillain, or has morals.
When do they team-up?
A dire, magnificent crisis
Sometimes, when an enemy or event, that heroes (or villains) alone can`t defeat, unorthodox actions must be performed. One of these can be a hero & villain team-up.
A personal crisis
When a villain needs something hes/she/it can`t get by her-/him/itself, they seek help from a hero. Or a hero from a villain.
No other choice, whatsoever
If both the villain and the hero (or more of them) are, for example, trapped somewhere where survival is difficult alone (because of another person, powers of nature etc.), they may end up working together. Usually they have a temporary bond between them, during the story. Temporary, because it usually breaks after the adventure is over.
How and why does it often end?
Normally, the team-up ends because co-operation is no longer needed, or the villain turns against the hero (in some rare cases, the other way around).
On rare occasions, the adventure changes one of the "team-uppers", to turn to a hero or a villain.
If a villain had been a hero for some reason, when the villain teamed up with the hero, it doesn`t count as a hero-villain team-up.
The heroes and villains in question don`t have to be super-, scifi-or any other genres heroes and villains. The fact that they`re heroes and the villains of the story.