For the most part it would seem that Thanos was in the Andromeda Galaxy.
Pre-Infinity War it seems Thanos has been going from planet to planet using his minions to take control and then execute half the population manually.
This is evidenced by the IW flashback of Gamora's adoption.
By the time The Avengers comes along, Thanos becomes aware that an Infinity Stone (the Space Stone in the Tesseract) has re-surfaced from being lost.
From there, various Infinity Stones come to light. The Reality Stone was lost (hidden by Bor, Odin's father) and the Time Stone protected by the Ancient One in Kamar-Taj, the Power Stone on Morag and found by Star-Lord etc.
So why now?
We do know that various Cosmic-level entities have been taken off the board between Avengers and Infinity War who may have have been restricting what he could do without popping up on their radar.
The Ancient One, defended Earth for centuries from mystical threats.
Odin was certainly aware of the Infinty Stones
Ego was a Celestial who should have been aware.
The Infinity Stones are an existential threat and, accordingly, Thanos has been using agents to locate and recover Infinity Stones.
He sends Loki to retrieve the Space Stone (Avengers) and Ronan (Guardians of the Galaxy) to collect the Power Stone.
Eventually though, after various failures, Thanos decides to do it himself after (it is assumed) the events of Age of Ulton although it's not clear when this event actually takes place in the MCU timeline
We do know that Thanos had the Infinity Gauntlet constructed by Eitri at Nedavellir but it's possible that this actually took place considerably after AoU and we are just seeing the outcome as a flash forward and Thanos really started getting serious about the Infinity Stones just before IW after Odin has moved on from Asgard and Nedavellir was left undefended.
Updated: Per this answer on SF&F
Per the film's Directors/Screenwriters Commentary, Thanos' motivation for deciding to gather the stones is that he finally (after many years of searching) learned the location of the lost Soul Stone. Before this he seems content to get on with obliterating one planet at a time and making sure that he knows roughly where the other stones are, safe in the knowledge that he's made himself powerful enough (through his armies and his 'children of Thanos') to go and collect them when the need arises.
Stephen McFeely: "The catalyst for the whole movie was when Thanos figured out where the Soul Stone was because he captured Nebula on his ship and rooted around in her brain and figured out that Gamora knew where the Soul Stone was."
Joseph Russo: "It's the reason why he hasn't gone for it before, because he knows that the minute he does, the forces of the universe are gonna line up against him. If he doesn't know where the Soul Stone is, then what's the point?"
Source